[gnumeric] DECIMAL: Implement this.



commit 3b9b561095a084c1ebf0008ba95a5f38c5529014
Author: Morten Welinder <terra gnome org>
Date:   Thu Mar 19 08:25:01 2015 -0400

    DECIMAL: Implement this.

 NEWS                       |    1 +
 plugins/fn-eng/ChangeLog   |    4 ++++
 plugins/fn-eng/functions.c |    8 +++++++-
 3 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index 36f3483..d49a3e8 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Morten:
        * Fix xlsx import of multiple axes.
        * Fix xlsx title export problem.
        * Improve test suite.
+       * Actually implement DECIMAL.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.21
diff --git a/plugins/fn-eng/ChangeLog b/plugins/fn-eng/ChangeLog
index 8b607b1..480c225 100644
--- a/plugins/fn-eng/ChangeLog
+++ b/plugins/fn-eng/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-19  Morten Welinder  <terra gnome org>
+
+       * functions.c (gnumeric_decimal): Implement.
+
 2015-03-04  Morten Welinder <terra gnome org>
 
        * Release 1.12.21
diff --git a/plugins/fn-eng/functions.c b/plugins/fn-eng/functions.c
index c71a27e..3c9fcf3 100644
--- a/plugins/fn-eng/functions.c
+++ b/plugins/fn-eng/functions.c
@@ -394,11 +394,17 @@ static GnmValue *
 gnumeric_decimal (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 {
        gnm_float base = value_get_as_float (argv[1]);
+       static gnm_float pow_2_40 = GNM_const(1099511627776.0);
 
        if (base < 2 || base >= 37)
                return value_new_error_NUM (ei->pos);
 
-       return value_new_error_NUM (ei->pos);
+       return val_to_base (ei, argv[0], NULL,
+                           (int)base, 10,
+                           0, pow_2_40 - 1,
+                           V2B_STRINGS_MAXLEN |
+                           V2B_STRINGS_BLANK_ZERO |
+                           V2B_NUMBER);
 }
 
 /***************************************************************************/


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