in reply to Re^2: Spaceship Zero
in thread Spaceship Zero
Care to explain what you mean that it won't handle zeros?
I think he's referring to the discrepancy between the documented behaviour (returning the sign of the number) and the actual behaviour (returning 0) for both positive and negative zeros.
$ perl -le'$x=+0.0; print $x; print $x<=>0' 0 0 $ perl -le'$x=-0.0; print $x; print $x<=>0' -0 0
It does produce the documented results for +inf and -inf, and a sane result for NaN.
$ perl -wle'$x=0+Infinity; print $x; print $x<=>0' inf 1 $ perl -wle'$x=0-Infinity; print $x; print $x<=>0' -inf -1 $ perl -wle'$x=0+NaN; print $x; print $x<=>0' nan Use of uninitialized value in print at -e line 1.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Spaceship Zero
by pKai (Priest) on Nov 10, 2008 at 11:44 UTC | |
by ikegami (Patriarch) on Nov 10, 2008 at 16:21 UTC | |
by tye (Sage) on Nov 10, 2008 at 17:16 UTC | |
by ikegami (Patriarch) on Nov 10, 2008 at 17:33 UTC |