[gnumeric] GUI: Use shortest round-tripping versions for constants in formulae.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Use shortest round-tripping versions for constants in formulae.
- Date: Sun, 21 Aug 2016 20:00:12 +0000 (UTC)
commit 4a112f1eb3a48e0e4b98bbb04bafaf835f90a8f9
Author: Morten Welinder <terra gnome org>
Date: Sun Aug 21 15:59:17 2016 -0400
GUI: Use shortest round-tripping versions for constants in formulae.
ChangeLog | 5 +++++
src/parse-util.c | 2 +-
src/value.c | 9 ++++++---
3 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 115ae93..7d88bdf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-21 Morten Welinder <terra gnome org>
+
+ * src/value.c (value_get_as_gstring): Let a negative
+ decimal_digits mean "shortest round-tripping string".
+
2016-08-20 Morten Welinder <terra gnome org>
* configure.ac: Post-release bump.
diff --git a/src/parse-util.c b/src/parse-util.c
index f9cb11f..45d0f4f 100644
--- a/src/parse-util.c
+++ b/src/parse-util.c
@@ -1475,7 +1475,7 @@ gnm_conventions_new_full (unsigned size)
convs->input.func = std_func_map;
convs->input.external_wb = std_external_wb;
- convs->output.decimal_digits = GNM_DIG;
+ convs->output.decimal_digits = -1;
convs->output.translated = TRUE;
convs->output.string = std_output_string;
convs->output.name = std_expr_name_handler;
diff --git a/src/value.c b/src/value.c
index 9f52201..d1b0daf 100644
--- a/src/value.c
+++ b/src/value.c
@@ -924,9 +924,12 @@ value_get_as_gstring (GnmValue const *v, GString *target,
return;
case VALUE_FLOAT:
- g_string_append_printf (target, "%.*" GNM_FORMAT_g,
- conv->output.decimal_digits,
- v->v_float.val);
+ if (conv->output.decimal_digits < 0)
+ go_dtoa (target, "!" GNM_FORMAT_g, v->v_float.val);
+ else
+ g_string_append_printf (target, "%.*" GNM_FORMAT_g,
+ conv->output.decimal_digits,
+ v->v_float.val);
return;
case VALUE_ARRAY: {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]