summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7649cd0)
raw | patch | inline | side by side (parent: 7649cd0)
author | Sebastian Harl <sh@tokkee.org> | |
Sun, 5 Oct 2014 18:39:33 +0000 (20:39 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sun, 5 Oct 2014 18:39:33 +0000 (20:39 +0200) |
This is much better human-readable and we don't need an exact representation.
In fact, given that a datum's string value is used when comparing attribute
values, the human readable format is much better suited given that chances are
higher that users will enter numbers in the same format (but it's still just a
best guess kind of thing).
In fact, given that a datum's string value is used when comparing attribute
values, the human readable format is much better suited given that chances are
higher that users will enter numbers in the same format (but it's still just a
best guess kind of thing).
src/core/data.c | patch | blob | history | |
t/unit/core/data_test.c | patch | blob | history |
diff --git a/src/core/data.c b/src/core/data.c
index eeead556899382b1e78270714a3e69eadc349129..48ca6b0bd74b9a4507c5a86b1c161d066d0f2cf7 100644 (file)
--- a/src/core/data.c
+++ b/src/core/data.c
/* log(64) */
return 20;
case SDB_TYPE_DECIMAL:
- /* XXX: -0xN.NNNNNNp+NNN */
+ /* XXX: -d.dddddde+dd or -ddddd.dddddd */
return 42;
case SDB_TYPE_STRING:
if (! datum->data.string)
ret = snprintf(buf, buflen, "%"PRIi64, datum->data.integer);
break;
case SDB_TYPE_DECIMAL:
- ret = snprintf(buf, buflen, "%a", datum->data.decimal);
+ ret = snprintf(buf, buflen, "%g", datum->data.decimal);
break;
case SDB_TYPE_STRING:
if (! datum->data.string)
index 6f9376ff48fdd5ad4a22b247bca20c6b5683dc41..484d59c64f9f10920648b027bac69dfa8002954a 100644 (file)
--- a/t/unit/core/data_test.c
+++ b/t/unit/core/data_test.c
},
{
{ SDB_TYPE_DECIMAL, { .decimal = 65536.0 } },
- "0x1p+16",
+ "65536",
+ },
+ {
+ { SDB_TYPE_DECIMAL, { .decimal = 12.3 } },
+ "12.3",
},
{
{ SDB_TYPE_STRING, { .string = NULL } },