| Thread overview |
|---|
October 04, 2012 Floats 1E-7 != 1.0E-7 | ||||
|---|---|---|---|---|
| ||||
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.
| ||||
October 04, 2012 Re: Floats 1E-7 != 1.0E-7 | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Paul | On Thursday, 4 October 2012 at 19:49:35 UTC, Paul wrote: > 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. Seems to be the same problem as discussed here: http://forum.dlang.org/thread/jsemibukuzkjssdbtkcf@forum.dlang.org | |||
October 05, 2012 Re: Floats 1E-7 != 1.0E-7 | ||||
|---|---|---|---|---|
| ||||
Posted in reply to anonymous | On Thursday, 4 October 2012 at 20:06:20 UTC, anonymous wrote:
> On Thursday, 4 October 2012 at 19:49:35 UTC, Paul wrote:
>> 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.
>
> Seems to be the same problem as discussed here: http://forum.dlang.org/thread/jsemibukuzkjssdbtkcf@forum.dlang.org
Thanks
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply