http://d.puremagic.com/issues/show_bug.cgi?id=8745
Summary: floating point comparison ("is" vs "==") inconsistency (on 32) Product: D Version: unspecified Platform: x86 OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: monarchdo...@gmail.com --- Comment #0 from monarchdo...@gmail.com 2012-10-01 14:21:50 PDT --- >From http://forum.dlang.org/group/digitalmars.D.learn //---- import std.stdio; import std.math; @property double getFloat() { return sqrt(1.1); } void main() { writeln(getFloat() == getFloat()); writeln(getFloat() is getFloat()); } //---- x32 Produces http://dpaste.dzfl.pl/e0e0bbae : false true x64 Produces http://dpaste.dzfl.pl/c1c7a415 : true true While one may argue that the comparison *may* return false, the difference in behavior between "==" and "is" not expected behavior (unless I'm missing something...? ). PS: the behavior difference is consistent http://dpaste.dzfl.pl/2ee9ae4e : //---- import std.stdio; import std.math; @property double getFloat() { return sqrt(1.1); } void main() { writeln(getFloat() == getFloat()); writeln(getFloat() is getFloat()); writeln(getFloat() is getFloat()); writeln(getFloat() == getFloat()); writeln(getFloat() is getFloat()); writeln(getFloat() == getFloat()); writeln(getFloat() == getFloat()); writeln(getFloat() is getFloat()); } //---- false true true false true false false true //---- On a side note, I find it strange that "==" return false in such a consistent manner. It might be over-sensitive to extended precision? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------