diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-11-12 12:22:55 +0900 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2014-11-20 05:46:18 +0100 |
commit | 8153386397087ce4f5c8997992edf5c1fd38b8db (patch) | |
tree | 889ec6c5b867202dd86053ac9c4169ec9a5e11f9 /doc/global | |
parent | 2810d7ee10c59b0486c12744a2bdf22856bfb81e (diff) |
Enhance precision of the FP conversion to strings in QVariant
This now guarantees that doing a round-trip from an FP number to string
and back to number results in the same number. This change is required
because DBL_DIG and FLT_DIG don't have the meaning that we were
expecting them to, here: they mean the minimum number of digits of
precision in decimal (i.e., changing the last decimal will always cause
the FP number to change). We need the maximum number: there is one
change in the last decimal place that causes the FP number to change.
IEEE 754 single-precision has 24 binary digits and double precision has
53 binary digits in their mantissa. To convert that to decimal, multiply
by the number of decimal digits a binary digit represents (log2(10) =
0.3), then add one for the rounding and one more digit for the actual
precision we want. That is, for floats we now ask for 9 digits and for
double, 17 decimal digits.
Task-number: QTBUG-42574
Change-Id: Ic78beb60a218f75322f832d33d63fd84e7a65b65
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'doc/global')
0 files changed, 0 insertions, 0 deletions