[gnumeric] LOG2: Use libc/libm's version.



commit 8b65c996de3464779f00f246d4c4b70a6c10c180
Author: Morten Welinder <terra gnome org>
Date:   Mon Mar 17 20:56:54 2014 -0400

    LOG2: Use libc/libm's version.
    
    It's not perfect, but close enough.  Ours wasn't any better.

 ChangeLog      |    2 +-
 configure.ac   |    2 +-
 src/mathfunc.c |   22 ----------------------
 src/mathfunc.h |    1 -
 src/numbers.h  |    2 ++
 5 files changed, 4 insertions(+), 25 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8043b28..fc0ecc7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,6 @@
 2014-03-17  Morten Welinder  <terra gnome org>
 
-       * src/mathfunc.c (gnm_log2): Normalize to ]0.5;1], not [0.5;1[.
+       * src/mathfunc.c (gnm_log2): Remove.  Use libm's log2.
 
 2014-03-16  Morten Welinder  <terra gnome org>
 
diff --git a/configure.ac b/configure.ac
index eaba17c..c43f047 100644
--- a/configure.ac
+++ b/configure.ac
@@ -648,7 +648,7 @@ AC_ARG_WITH(long_double,
                               ,
                               AC_MSG_ERROR([libgoffice needs to be compiled with long double support.]))
 
-               AC_CHECK_FUNCS(fabsl sqrtl expl expm1l logl log10l log1pl ceill floorl powl hypotl \
+               AC_CHECK_FUNCS(fabsl sqrtl expl expm1l logl log2l log10l log1pl ceill floorl powl hypotl \
                                sinl cosl tanl asinl acosl atanl atan2l fmodl lgammal lgammal_r \
                                sinhl coshl tanhl asinhl acoshl atanhl \
                                isnanl finitel,
diff --git a/src/mathfunc.c b/src/mathfunc.c
index 8fa09ec..29cbec2 100644
--- a/src/mathfunc.c
+++ b/src/mathfunc.c
@@ -311,28 +311,6 @@ bd0(gnm_float x, gnm_float M)
        return yh + yl;
 }
 
-gnm_float
-gnm_log2 (gnm_float x)
-{
-       int e;
-
-       if (x == 0)
-               return gnm_ninf;
-
-       if (x < 0)
-               return gnm_nan;
-
-       if (!gnm_finite (x))
-               return x;
-
-       /* This split ensures accurate integer results for 2^x.  */
-       x = gnm_frexp (x, &e);
-       if (x == 0.5)
-               x = 1.0, e--;
-
-       return e + gnm_log (x) / M_LN2gnum;
-}
-
 /* ------------------------------------------------------------------------- */
 /* --- BEGIN MAGIC R SOURCE MARKER --- */
 
diff --git a/src/mathfunc.h b/src/mathfunc.h
index d86d162..e24fa05 100644
--- a/src/mathfunc.h
+++ b/src/mathfunc.h
@@ -27,7 +27,6 @@ G_BEGIN_DECLS
 
 /* ------------------------------------------------------------------------- */
 
-gnm_float gnm_log2 (gnm_float x);
 gnm_float log1pmx (gnm_float x);
 gnm_float swap_log_tail (gnm_float lp);
 gnm_float pow1p (gnm_float x, gnm_float y);
diff --git a/src/numbers.h b/src/numbers.h
index 9c374e1..3ef9565 100644
--- a/src/numbers.h
+++ b/src/numbers.h
@@ -67,6 +67,7 @@ typedef long double gnm_float;
 #define gnm_log logl
 #define gnm_log10 log10l
 #define gnm_log1p log1pl
+#define gnm_log2 log2l
 #define gnm_modf modfl
 #define gnm_nan go_nanl
 #define gnm_ninf go_ninfl
@@ -178,6 +179,7 @@ typedef double gnm_float;
 #define gnm_log log
 #define gnm_log10 log10
 #define gnm_log1p log1p
+#define gnm_log2 log2
 #define gnm_modf modf
 #define gnm_nan go_nan
 #define gnm_ninf go_ninf


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