digitalmars.D.bugs - [Issue 3632] New: modify float is float to do a bitwise compare
- d-bugmail puremagic.com Dec 18 2009
- d-bugmail puremagic.com Dec 18 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3632 Summary: modify float is float to do a bitwise compare Product: D Version: unspecified Platform: Other OS/Version: Linux Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: schveiguy yahoo.com --- Comment #0 from Steven Schveighoffer <schveiguy yahoo.com> 2009-12-18 12:04:05 PST --- I was trying to test that my array append code is working properly. In order to do this, I want to verify that when I set the length to a larger number that the additional space is filled with T.init This test works great for most all types except floating point: assert(a[$-1] is T.init) It was pointed out that Phobos has isIdentical, but that doesn't work with literals for some reason: float a; assert(isIdentical(a, float.init)) // fails! But it shouldn't be this hard. Why does 'is' do a bitwise compare for everything *except* floating point numbers? I understand that the spec states that is converts to == for builtin types, but it seems inconsistent because == for all builtin types except floating point *is* a bitwise compare. It seems there is no easy way to get a bitwise compare for floating points, and the method provided doesn't work properly. It should be braindead simple to get the compiler to do a bitwise compare. I propose that for floating point types, x is y be equivalent to a bitwise compare. It is easy to say in the spec "x is y does a bitwise compare, which for all builtin types except for floating point types is equivalent to equality" -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 18 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3632 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au --- Comment #1 from Don <clugdbug yahoo.com.au> 2009-12-18 22:49:41 PST --- (In reply to comment #0)It was pointed out that Phobos has isIdentical, but that doesn't work with literals for some reason: float a; assert(isIdentical(a, float.init)) // fails!
That's because of the recently discovered NaN bug; the code generated for uninitialized floats and doubles needs to change. It's not a problem with isIdentical.But it shouldn't be this hard. Why does 'is' do a bitwise compare for everything *except* floating point numbers?
I propose that for floating point types, x is y be equivalent to a bitwise compare. It is easy to say in the spec "x is y does a bitwise compare, which for all builtin types except for floating point types is equivalent to equality"
I think this would be a good idea. I've thought that several times myself. I created the isIdentical() function because I think there's a need for it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 18 2009








d-bugmail puremagic.com