Yes, but shouldn't I avoid the representation
problem if the string I use to build my INSERT command is obtained through
double writtendouble=atof("0.1234567890123456");
stream << "'" << writtendouble << "'" // stream
is a string stream whose precision is set to 30 ????
By doing this way, I expected the INSERT command
use a string whose double representation would be exactly writtendouble.
thank you
Stéphane
PS:
Thanks Igor for the links, it's exactly what I
was looking for (and even more :) )
At 14:52 12/09/2007, Igor Tandetnik wrote:
Stéphane Thiers
<stephane.thiers-JhUR7tGRpkB8UrSeD/[EMAIL PROTECTED]> wrote:
If you do:
INSERT INTO myTable
VALUES('0.12345678901234559') // the column is of REAL type
and read back the value
SELECT * FROM myTable
then you get a value==0.12345678901234600 !!
the 2 values are different. What's the problem??
There is an infinite number of strings
consisting of decimal digits, but only a finite
number of distinct floating point values
representable in 64 bits. Thus, it is clearly
impossible for every such string to round-trip
through the floating number and back without
loss. What you see is a rounding error. For more
details (than you ever wanted to know), see
http://blogs.sun.com/darcy/resource/Wecpskafpa-ACCU.pdf
http://docs.sun.com/source/806-3568/ncg_goldberg.html
Igor Tandetnik
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------
Stéphane Thiers
Data Systems, Lancelot Applications Software Group Engineer
Scientific Instruments
Varian Data Systems S.A.S
1 Rue Hector Berlioz
ZAC DES PLANS
F-38600 FONTAINE
FRANCE
Tel: +33 4 76 53 35 80
Fax: +33 4 76 53 35 89
[EMAIL PROTECTED]
http://www.varianinc.com
Inspiring Excellence