[2263] XML dump of DOUBLE rounds values
Charles Yeomans
charles at declareSub.com
Mon Mar 26 16:52:48 CDT 2007
On Mar 26, 2007, at 5:58 PM, Ruslan Zasukhin wrote:
> Hi All,
>
> Well, after some play I have found not nice things.
>
>
> -------------
> * we have in C/C++ language some DOUBLE value
>
> double dv = 10149.25;
>
>
> -------------
> * we do standard C call
>
> printf( buff, "%G", dv );
>
> And we get
> buff = "10149.2" on MAC, XCODE
> buff = "10149.3" on WIN, MS Visual
>
> -------------
> * IF to increase precision
> printf( buff, "%.40G", dv );
>
> We get something as
>
> buff = "10149.2500036346345676547567567785678"
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unexpected trail.
>
>
> --------------
> RESUME:
>
> there is no technical way convert any possible DOUBLE VALUE
> into string accurately.
>
>
> This is why I again want to point. If you need EXACT storage of
> numbers,
> DO NOT use DOUBLE/FLOAT type.
Why not dump doubles by casting them to an 8-byte string, then
base-64-encoding that?
Charles Yeomans
More information about the Valentina
mailing list