shithub: mc

Download patch

ref: bc7b9cf7c49595c758d68c30ee1179740e269121
parent: f6e3a00fc29a7770b39c1ad51e4cfbff305bda38
author: S. Gilles <[email protected]>
date: Thu Jun 28 06:33:47 EDT 2018

Fix pi/2 constants.

--- a/lib/math/ancillary/pi-constants.c
+++ b/lib/math/ancillary/pi-constants.c
@@ -48,9 +48,10 @@
 
         printf("\n");
         printf("1000 bits of pi/2:\n");
+        mpfr_const_pi(pi, MPFR_RNDN);
+        mpfr_div_si(pi, pi, 2, MPFR_RNDN);
 
         for (int bits_obtained = 0; bits_obtained < 1000; bits_obtained += 53) {
-                mpfr_div_si(pi, pi, 2, MPFR_RNDN);
                 d = mpfr_get_d(pi, MPFR_RNDN);
                 u = FLT64_TO_UINT64(d);
                 printf("%#018lx\n", u);
@@ -66,7 +67,6 @@
         d = mpfr_get_d(pi, MPFR_RNDN);
         u = FLT64_TO_UINT64(d);
         printf("%#018lx\n", u);
-
         printf("\n");
         printf("Pre-computed 1/(pi/1024):\n");
         mpfr_const_pi(pi, MPFR_RNDN);
--- a/lib/math/sin-impl.myr
+++ b/lib/math/sin-impl.myr
@@ -53,9 +53,9 @@
 /* Pi/2 in lots of detail, for range reducing sin(2^18) or so */
 const pi_over_2 : uint64[4] = [
 	0x3ff921fb54442d18,
-	0x3c81a62633145c07,
-	0xb8ff1976b7ed8fbc,
-	0x3584cf98e804177d,
+	0x3c91a62633145c07,
+	0xb91f1976b7ed8fbc,
+	0x35b4cf98e804177d,
 ]
 
 /* Pre-computed inverses */