I'm doing some numerical stuff where I'll doubtless run into NaN, and I find that Java's treatment of NaN doesn't come over into Fantom.
Specifically, Java defines the static method Double.isNaN(), which returns true for a NaN argument. It would be nice if this was available.
Also, I discovered that (since NaN is not equal to anything) you can just use d == d for some double variable a, and it evaluates to false (!) if d is NaN. This works for compiled Fantom, but does not work in fansh.
brianFri 22 Oct 2010
For some reason I thought I had Float.isNaN, but I guess not. I pushed a fix for that.
I really dislike the Java semantics, but since Float.equals and Float.compare compiles down to their single Java bytecode it was the only efficient way to do it. Note however that Float.compare or the <=> operator considers two NaNs equal:
yachris Fri 22 Oct 2010
Hello,
I'm doing some numerical stuff where I'll doubtless run into NaN, and I find that Java's treatment of NaN doesn't come over into Fantom.
Specifically, Java defines the static method
Double.isNaN()
, which returnstrue
for a NaN argument. It would be nice if this was available.Also, I discovered that (since NaN is not equal to anything) you can just use
d == d
for some double variablea
, and it evaluates tofalse
(!) ifd
is NaN. This works for compiled Fantom, but does not work in fansh.brian Fri 22 Oct 2010
For some reason I thought I had Float.isNaN, but I guess not. I pushed a fix for that.
I really dislike the Java semantics, but since Float.equals and Float.compare compiles down to their single Java bytecode it was the only efficient way to do it. Note however that Float.compare or the
<=>
operator considers two NaNs equal: