>>>>> "Dimitri" == Dimitri Maziuk <dmaziuk@yola.bmrb.wisc.edu> writes:
Dimitri> * Craig Dickson (crdic@yahoo.com) spake thusly:
>> I don't see how. I see it as a legitimate compiler
>> optimization. If you have "double f = 4;", and you compile 4 as
>> a double-precision value rather than as an int (which would
>> then require an immediate conversion), how could that possibly
>> break a program?
Dimitri> Very simple: double f = 4 may be converted to
Dimitri> eg. 4.000000000000000001234,
No way in hell. As double has a 50+ bit mantissa, all ints smaller
than this (typical 4 byte long int) can be converted without loss.
(IEEE 754 53 bits mantissa, 10 bits exponent, 1 bit sign... IIRC)
Yes, I'm nitpicking, why do you ask?
Dimitri> and any test for (sqrt(f) == 2.0) will fail. Of course if
Dimitri> your (generic "you", not personal) code is like that, you
Dimitri> probably shouldn't be playing with floats.
<sound of hammer hitting end of nail>
"playing with floats"... nice turn of phrase ;-)
Dimitri> Besides, given the choice between specifying something
Dimitri> explicitly and trusting a compiler to figure it out for
Dimitri> me, guess what I choose?
Well... <plug type="stupid">then you probably like Python, as one of
it's (inofficial) mottos is "explicit is better than implicit"</plug>
<wink>
Bye, J
--
Jürgen A. Erhard (juergen.erhard@gmx.net, jae@users.sf.net)
My WebHome: http://members.tripod.com/Juergen_Erhard
Give a man fire and he will be warm for a day.
Set a man on fire and he will be warm for the rest of his life.
Attachment:
pgpk4KBtw7Ou8.pgp
Description: PGP signature