[Issue 3632] New: modify float is float to do a bitwise compare
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Dec 18 12:04:06 PST 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 at puremagic.com
ReportedBy: schveiguy at yahoo.com
--- Comment #0 from Steven Schveighoffer <schveiguy at 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: -------
More information about the Digitalmars-d-bugs
mailing list