Eliot Frank
2008-06-13 19:37:55 UTC
AnsiString as = "12.34";
double a = as.ToDouble();
It appears that there are only zeros in the double beyond the last
significant digit. Is this always the case?
No. There is NO guarantee that any decimal fraction can be representeddouble a = as.ToDouble();
It appears that there are only zeros in the double beyond the last
significant digit. Is this always the case?
exactly in floating point because internal format is a binary fraction.
Your number may be 12.339999999999999 internally but gets rounded back
to 12.34 on output.
Is there a simple way to determine either the precision or the number of
significant digits of an existing double?
No. You could do it algorithmically, using an algorithm similar to thatsignificant digits of an existing double?
AnsiString uses to decide to represent a number.
-Eliot