[gnumeric] reduce_pi_half: ensure ieee semantics for doubles.



commit 2caadce4a123368a7c235d20142dee08bc0e6b2e
Author: Morten Welinder <terra gnome org>
Date:   Sat Nov 16 12:11:16 2013 -0500

    reduce_pi_half: ensure ieee semantics for doubles.

 src/sf-trig.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/sf-trig.c b/src/sf-trig.c
index e04e63e..93e3d1b 100644
--- a/src/sf-trig.c
+++ b/src/sf-trig.c
@@ -373,15 +373,26 @@ reduce_pi_half_full (gnm_float x, int *km4)
 static gnm_float
 reduce_pi_half (gnm_float x, int *km4)
 {
+       void *state;
+       gnm_float xr;
+
        if (gnm_isnan (x))
                return x;
 
        g_assert (x >= 0);
 
+       /*
+        * We aren't actually using quads, but we rely somewhat on
+        * proper ieee double semantics.
+        */
+       state = gnm_quad_start ();
        if (x < (1u << 26))
-               return reduce_pi_half_simple (x, km4);
+               xr = reduce_pi_half_simple (x, km4);
        else
-               return reduce_pi_half_full (x, km4);
+               xr = reduce_pi_half_full (x, km4);
+       gnm_quad_end (state);
+
+       return xr;
 }
 
 gnm_float


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]