digitalmars.D.bugs - [Issue 7836] New: NaNs inside associative array don't use normal FP equality
- d-bugmail puremagic.com (38/43) Apr 05 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7836
- d-bugmail puremagic.com (11/11) Apr 14 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7836
- d-bugmail puremagic.com (18/18) Jul 08 2013 http://d.puremagic.com/issues/show_bug.cgi?id=7836
http://d.puremagic.com/issues/show_bug.cgi?id=7836 Summary: NaNs inside associative array don't use normal FP equality Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: druntime AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc I don't know if this is a bug, or if here D/DMD is working as designed. I am not sure. This code shows that floating point NaNs are not tested with == inside associative arrays (because NaNs != NaNs): import std.stdio: writeln; void main() { int[double] aa; aa[double.nan] = 1; writeln(aa); aa[double.nan] = 2; writeln(aa); } Output DMD 2.059beta: [nan:1] [nan:2] Python uses == to compare dict (associative array) keys, so NaNs can't overwrite each other:{nan: 1}a = {} a[float("nan")] = 1 a{nan: 1, nan: 2} So maybe DMD has to act as Python in this case. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------a[float("nan")] = 2 a
Apr 05 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7836 hsteoh quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hsteoh quickfur.ath.cx This is an AA implementation bug. Internally, AA's use bitwise comparison, which is wrong in many cases. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 14 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7836 hsteoh quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- OS/Version|Windows |All Actually, this bug has nothing to do with AA's. The problem is that double's typeinfo.equals and typeinfo.compare does not respect NaNs: import std.stdio: writeln; void main() { double x = double.nan, y = double.nan; writeln(x == y); // prints false (OK) writeln(typeid(double).equals(&x, &y)); // prints true (WRONG) writeln(typeid(double).compare(&x, &y)); // prints 0 (WRONG) } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 08 2013