digitalmars.D.bugs - [Issue 3928] New: Comparing imaginaries with reals produces results that are inconsistent
- d-bugmail puremagic.com (93/93) Mar 10 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3928
- d-bugmail puremagic.com (11/11) Mar 14 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3928
- d-bugmail puremagic.com (10/10) Jan 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3928
- d-bugmail puremagic.com (14/14) Jan 23 2012 http://d.puremagic.com/issues/show_bug.cgi?id=3928
http://d.puremagic.com/issues/show_bug.cgi?id=3928 Summary: Comparing imaginaries with reals produces results that are inconsistent Product: D Version: 2.041 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: crimson.magus gmail.com PST --- Comparing an imaginary number like an ifloat with a real one like a float: 1. Has results that differ at compile time and runtime. 2. At runtime is done in the wrong order. 3. Doesn't seem to be very meaningful, given that you can't compare complex numbers. With respect to each issue above, here are some more details. 1. Different results at runtime and compile time. At compile time, if the left is imaginary, then we take the imaginary part of the right side and compare the two. If the left side is real, then we take the real part of the right side and compare. All of this is as seen in constfold.c. At runtime, we turn both sides into complex numbers by making a missing part zero. Then, we compare the imaginary parts, and if they're equal, compare the real parts. 2. Wrong order at runtime. left instead of left to right. If my program has "a < b", then "b < a" is checked. 3. Meaning? Comparisons where at least one side is a complex number are not allowed in D. As such, is it meaningful to allow the comparisons described here, given that such numbers are treated as complex numbers and compared? Note, all of this is strictly where one side of a compare expression is an imaginary number and the other is a real number. Here's a sample program: import std.stdio; void main() { cfloat cf1 = 1 + 2i; cfloat cf2 = 3 + 4i; ifloat if2 = 1i; float f2 = 3; ifloat if3 = 4i; float f3 = 2; ifloat if4 = 5i; float f4 = 5; writeln( "--- < ---" ); writeln( if2 < f2 ); writeln( f2 < if2 ); writeln( if3 < f3 ); writeln( f3 < if3 ); writeln( if4 < f4 ); writeln( f4 < if4 ); writeln( 1i < 3 ); writeln( 3 < 1i ); writeln( 4i < 2 ); writeln( 2 < 4i ); writeln( 5i < 5 ); writeln( 5 < 5i ); writeln( "--- == ---" ); writeln( if2 == f2 ); writeln( f2 == if2 ); writeln( if3 == f3 ); writeln( f3 == if3 ); writeln( if4 == f4 ); writeln( f4 == if4 ); writeln( 1i == 3 ); writeln( 3 == 1i ); writeln( 4i == 2 ); writeln( 2 == 4i ); writeln( 5i == 5 ); writeln( 5 == 5i ); writeln( "--- > ---" ); writeln( if2 > f2 ); writeln( f2 > if2 ); writeln( if3 > f3 ); writeln( f3 > if3 ); writeln( if4 > f4 ); writeln( f4 > if4 ); writeln( 1i > 3 ); writeln( 3 > 1i ); writeln( 4i > 2 ); writeln( 2 > 4i ); writeln( 5i > 5 ); writeln( 5 > 5i ); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 10 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3928 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au It's simpler than that. Comparisons between a pure imaginary and a pure real are nonsense, and shouldn't compile. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 14 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3928 Andrei Alexandrescu <andrei metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |andrei metalanguage.com AssignedTo|nobody puremagic.com |andrei metalanguage.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 09 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3928 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEW CC| |bugzilla digitalmars.com Version|2.041 |D1 OS/Version|Windows |All 15:43:39 PST --- Built-in complex numbers are deprecated anyway for D2, so redone as a D1 only issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 23 2012