Fun with floating point
Kenny via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Feb 7 13:33:46 PST 2015
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?
p.s. the final code used by both compilers:
import std.stdio;
import std.conv;
int main(string[] argv)
{
const float eps = 1.0f;
float f = 0.0f;
while (f + eps != f)
f += 1.0f;
writeln("eps = ", eps, ", max_f = ", f);
return 0;
}
More information about the Digitalmars-d-learn
mailing list