[Bug 45] Bug in conversion of floating point literals

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 16 00:16:53 PST 2006


http://d.puremagic.com/bugzilla/show_bug.cgi?id=45





------- Comment #4 from clugdbug at yahoo.com.au  2006-03-16 02:16 -------
(In reply to comment #3)
> I'm deffinatly on the "literal defines precision" side, but have a look
> at:
> http://d.puremagic.com/bugzilla/show_bug.cgi?id=21

In his reply to that comment, Walter states:
"D always tries to do any compile time evaluation of floating
point constants at max precision."

That's perfectly reasonable, too. But it means that there's still a bug, but
it's a different one now: floating point constants are not evaluated at max
precision in assignment statements. But there's definitely something weird
going on. Apparently, const double doesn't exist.

const float f = real.max;
real r = f;

This sets r = real.max. That's incredible, because a number that large cannot
be stored in a float. If this behaviour is to remain, then 'const float' and
'const double' should be removed from the language, along with the 'f' and 'L'
suffixes : all floating point constants are real.

However,

real r2;
r2 = f;

sets r2 = real.inf, which is what I would expect - real.max can't be stored in
a float, so it became an infinity.


-- 




More information about the Digitalmars-d-bugs mailing list