digitalmars.D.bugs - [Issue 3970] New: Problem with cast -1.0L ==> uint/ulong
- d-bugmail puremagic.com (29/29) Mar 15 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3970
- d-bugmail puremagic.com (21/21) Mar 15 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3970
- d-bugmail puremagic.com (20/20) Jan 07 2013 http://d.puremagic.com/issues/show_bug.cgi?id=3970
- d-bugmail puremagic.com (11/11) Jan 07 2013 http://d.puremagic.com/issues/show_bug.cgi?id=3970
http://d.puremagic.com/issues/show_bug.cgi?id=3970 Summary: Problem with cast -1.0L ==> uint/ulong Product: D Version: 2.041 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc This program compiles and runs with no errors, Don and Aldo Nunez think there are some inconcistancies here: void main() { static assert((cast(ushort)(-1.0L)) == 0xFFFF); static assert((cast(uint)(-1.0)) == 0); static assert((cast(uint)(-1.0L)) == 0); static assert((cast(ulong)(-1.0L)) == 0xbff0000000000000UL); assert((cast(ushort)(-1.0L)) == 0xFFFF); assert((cast(uint)(-1.0)) == 0); assert((cast(uint)(-1.0L)) == 0); assert((cast(ulong)(-1.0L)) == 0xbff0000000000000UL); } Don>The cast(uint) case is clearly a bug.< -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 15 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3970 Aldo Nunez <aldonunez1 gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aldonunez1 gmail.com --- It seems like the runtime casting of (float, double, real -> uint) and (float, double -> ulong) can be done simpler, and in a way that would fix the -1.0 -> 0 bug. When converting from float or double to ulong; why can't it be done like real to ulong, where there is a simple conversion in x87 registers plus a fixup for ulong values greater than long.max? When converting from FP to uint; why can't it be done like FP to ushort, where there is a simple conversion to int with x87 registers, and then a truncation? This would make all floating point to integer conversions consistent, and get rid of this bug where an FP -1 turns into an integer 0xFF... in some cases, and in others 0. It should always be 0xFF..., just like a signed integer to unsigned conversion. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 15 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3970 This passes on Linux32 and 64, on 1.076 and 2.061. Also tested on D1.073 so it has been working for quite some time on Linux. Need to check if it is Windows-specific. void main() { static assert((cast(ushort)(-1.0)) == 0xFFFF); static assert((cast(ushort)(-1.0L)) == 0xFFFF); static assert((cast(uint)(-1.0)) == 0xFFFF_FFFF); static assert((cast(uint)(-1.0L)) == 0xFFFF_FFFF); static assert((cast(ulong)(-1.0L)) == 0xFFFF_FFFF_FFFF_FFFFUL); assert((cast(ushort)(-1.0)) == 0xFFFF); assert((cast(ushort)(-1.0L)) == 0xFFFF); assert((cast(uint)(-1.0)) == 0xFFFF_FFFF); assert((cast(uint)(-1.0L)) == 0xFFFF_FFFF); assert((cast(ulong)(-1.0L)) == 0xFFFF_FFFF_FFFF_FFFFUL); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 07 2013
http://d.puremagic.com/issues/show_bug.cgi?id=3970 Simen Kjaeraas <simen.kjaras gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |simen.kjaras gmail.com PST --- Just tested on Windows. First two asserts and static asserts pass, the rest fail. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 07 2013