[2263] XML dump of DOUBLE rounds values
Stan Busk
maxprog at mac.com
Tue Mar 27 04:20:54 CDT 2007
Hi,
Personally I use a 'precision' value to compare doubles. Something like:
If Abs( Abs( Value1 ) - Abs( Value2 ) ) > aPrecision then msgbox
"Value1 <> Value2"
If Abs( Abs( Value1 ) - Abs( Value2 ) ) <= aPrecision then msgbox
"Value1 = Value2"
Where aPrecision is '0.01' for 2 decimals values.
Of course I am comparing money amount.
In mySQL there is a type for that, DECIMAL.
^^^^^^^
From mySQL doc.:
"The DECIMAL and NUMERIC data types are used to store exact numeric
data values. In MySQL, NUMERIC is implemented as DECIMAL. These types
are used to store values for which it is important to preserve exact
precision, for example with monetary data. As of MySQL 5.0.3, DECIMAL
and NUMERIC values are stored in binary format. Previously, they were
stored as strings, with one character used for each digit of the
value, the decimal point (if the scale is greater than 0), and the
‘-’ sign (for negative numbers)."
More here: http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
Could such type be added to Valentina? That would be handy.
Stan
> On 27/3/07 12:15 AM, "Thorsten Hohage"
> <thohage at objectmanufactur.com> wrote:
>
>>> This is why I again want to point. If you need EXACT storage of
>>> numbers,
>>> DO NOT use DOUBLE/FLOAT type.
>>
>> Yes and the most important problem is not retrieving "correct" value,
>> but comparing two values, because on a computer using rounding/
>> truncation you've got uncountable (right translation?) different
>> "zeros"!
>
> Yes, if you remember in PASCAL comparison of 2 double values was
> prohibited
> at all.
>
> C/C++ allow you write
>
> if( dv1 == dv2 )
>
> But this is potential bug.
>
>
>
> --
> 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]
>
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
More information about the Valentina
mailing list