[2263] XML dump of DOUBLE rounds values

Ruslan Zasukhin sunshine at public.kherson.ua
Tue Mar 27 01:58:32 CDT 2007


On 26/3/07 11:52 PM, "Charles Yeomans" <charles at declareSub.com> wrote:

>> -------------
>> * 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?

If talk about XML dump then yes we can do next:
    
    just dump DOUBLE value as string of 8 hex bytes
    this will EXACTLY mirror state of memory...
    also we need always dump bytes e.g. In BigEndian order.
    
But Ivan say -> XML format by idea, should be human readable and editing.

---
More problems with SQL dump then. Here we exactly cannot use hex value of
double...or we can ... As   VALUES ( 0xA43D5F7H )

It needs to think more ...


-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list