[Issue 3632] modify float is float to do a bitwise compare

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 28 05:01:40 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=3632



--- Comment #17 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-06-28 04:56:43 PDT ---
(In reply to comment #11)
> The use case I can remember being discussed is using 'v is float.init' to
> determine if a floating point value is uninitialized or is a nan due to the
> result of a calculation.
> 
[snip]
> 
> Maybe Steven or Don have an opinion on this feature they asked for?
> 'isIdentical' seems to do a straight bitwise comparison.

Quite simply, the above (v is float.init) is my use case.  In some parts of the
code, the runtime is responsible for default initializing data.  I wanted to
verify that my code was properly initializing the data to T.init.

This is impossible without casting the value to a ubyte[] array to do a
comparison (and even then, it's not quite right, because you can have garbage
data in some cases).

But it makes no sense to me for is to ever do anything but a bitwise compare.

In other words, given any type T (and I mean any type T):

foo(T t)
{
assert(t is t);
}

should always pass.  It makes no sense to me for is to do anything else -- it's
low-level bitwise comparison that bypasses any operators.

To make this true for every type *except* floating point types seems like a
huge inconsistency.

-- 
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