[gnumeric] LOG2: fix accuracy. Again.



commit a1f3b1b06ad0e22366d4c8516b37a76160c2dfaa
Author: Morten Welinder <terra gnome org>
Date:   Mon Mar 17 13:48:06 2014 -0400

    LOG2: fix accuracy.  Again.

 ChangeLog      |    4 ++++
 NEWS           |    1 +
 src/mathfunc.c |    2 ++
 3 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a323cb6..8043b28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-03-17  Morten Welinder  <terra gnome org>
+
+       * src/mathfunc.c (gnm_log2): Normalize to ]0.5;1], not [0.5;1[.
+
 2014-03-16  Morten Welinder  <terra gnome org>
 
        * src/expr.c (gnm_expr_eval): Survive dynamic deps in conditional
diff --git a/NEWS b/NEWS
index e1a080d..d276d0e 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,7 @@ Morten:
        * Fix crash reading strange xls file.  [Redhat #1076912]
        * Fix problem clearing existing values in some xlsx cells.  [#726297]
        * Fix criticals for dynamic deps in conditional formats.  [#726163]
+       * Fix LOG2 problem.  [#726464]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.12
diff --git a/src/mathfunc.c b/src/mathfunc.c
index 3efa808..8fa09ec 100644
--- a/src/mathfunc.c
+++ b/src/mathfunc.c
@@ -327,6 +327,8 @@ gnm_log2 (gnm_float 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;
 }


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