[gnumeric] MROUND: drop stange 0.0000003 addition.



commit f7fddc3be622e2e31dfde67ad03271a9af5e45e2
Author: Morten Welinder <terra gnome org>
Date:   Sat Oct 30 20:21:31 2021 -0400

    MROUND: drop stange 0.0000003 addition.

 NEWS                        | 1 +
 plugins/fn-math/functions.c | 6 ++----
 2 files changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index 774038ad4..512d14075 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Morten:
        * Fix applix import/locale problem.
        * Make sure CEIL doesn't return -0.  [#603]
        * Add ILOG function.  [#591]
+       * Fix MROUND.  [#604]
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.50
diff --git a/plugins/fn-math/functions.c b/plugins/fn-math/functions.c
index 20f6d2ce8..a0077f726 100644
--- a/plugins/fn-math/functions.c
+++ b/plugins/fn-math/functions.c
@@ -2373,7 +2373,6 @@ static GnmFuncHelp const help_mround[] = {
 static GnmValue *
 gnumeric_mround (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 {
-       gnm_float const accuracy_limit = 0.0000003;
        gnm_float number, multiple;
        gnm_float div, mod;
        int     sign = 1;
@@ -2396,10 +2395,9 @@ gnumeric_mround (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
        }
 
        mod = gnm_fmod (number, multiple);
-       div = number - mod;
+       div = (mod >= multiple / 2 ? multiple : 0) + (number - mod);
 
-       return value_new_float (sign * (
-                                       div + ((mod + accuracy_limit >= multiple / 2) ? multiple : 0)));
+       return value_new_float (sign * div);
 }
 
 /***************************************************************************/


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