Erik Wikström wrote:
Quote:
On 2007-09-03 18:03, Victor Bazarov wrote:
Quote:
>
PengYu.UT@gmail.com wrote:
Quote:
>>I setprecision to be 100 for both cases. I'm wondering why the
>>number of digits are different.
>>[..]
>>$ ./main-g.exe
>>0.0100000000000000002081668171172168513294309377 6702880859375
>>1.0000000000000000208166817117216851329430937767 02880859375000000000000000000000000000000000000000 0000e-02
>>
>I believe 'fixed' (the default, when 'scientific' is not used),
>always skips the trailing zeros.
>
Running the same code under Windows using VC++ 2005 I get the same
number of digits printed, but it's all zeroes after the 1. I find
that a bit troubling, since I thought that 0.01 was a number that
couldn't be exactly represented.
What you see is the external equivalent of the imprecise internal
representation. A decent library should be able to successfully
round the number when outputting is so that the round-trip (no pun
indended) from external rep to internal and back to external does
not change the appearance of the number. "0.01" in--0xB1AB1AAA (or
whatever) out--"0.01"
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask