Fun with floating point

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Feb 8 00:40:54 PST 2015


On Sat, 07 Feb 2015 21:33:46 +0000, Kenny wrote:

> The above code snippet works correctly when I use LDC compiler (it finds
> expected 'f' value and prints it to console). I'm wondering is it a bug
> in DMD?

nope, this is a bug in your code. compiler (by the specs) is free to 
perform intermediate calculations with any precision that is not lower 
than a highest used type (i.e. not lower that `float`'s one for `while` 
condition (`f + eps != f`). it may be even infinite precision, so your 
code may not exit the loop at all.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150208/29d3e0b2/attachment.sig>


More information about the Digitalmars-d-learn mailing list