On Saturday, 14 May 2016 at 20:41:12 UTC, Era Scarecrow wrote:
The real reason it's false is because you're comparing against an immutable (constant), or my results lead me to believe that; Otherwise why could cf and If work?

The "immutable" is of type real... Unfortunately the "cf" is also computing as real whereas "f" is implicitly converted to real from float. It makes comparing floating point types for equality implementation defined in D, i.e. unreliable.

The assignment to "cf" ought to have brought cf to 32 bit float.

So the "false" results are the correct ones, and the "true" are the unexpected ones where you compare different types.

import numpy
f=numpy.float32(1.30)
r=numpy.float64(1.30)
print r==f  # false

Reply via email to