Floats 1E-7 != 1.0E-7

Paul phshaffer at gmail.com
Thu Oct 4 12:43:43 PDT 2012


This is my test code:

import std.stdio;
import std.conv;
import std.string;

void main(string args[])
{
writeln(to!float(args[1])==to!float(args[2]));
}

When I enter 1E-7 and 1.0E-7 for arguments I get "false".

Why aren't these equal?  When parsing a text file that reads
these two values I need it to say they are equal.

Thanks.


More information about the Digitalmars-d-learn mailing list