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

--- Comment #0 from Steven Schveighoffer <> 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

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to