Open Yaffle opened 10 years ago
I'm getting a zero
var bd = require('bigdecimal') undefined new bd.BigInteger("-1").compareTo(new bd.BigInteger("-1")) 0
gmelika, even though it displays as "0", it is apparently actually a -0. You will see this if you divide one by that value as Yaffle has done. Here is a JSFiddle: http://jsfiddle.net/ue0mru55/
It basically shows that
new BigInteger("-1").compareTo(new BigInteger("-1")) => 0
and
1 / new BigInteger("-1").compareTo(new BigInteger("-1")) => -Infinity
Would it be possible and reasonable to wrap the result of compareTo() in Math.abs()?
Yaffle, just for my reference, does it matter if compareTo() returns -0?
@thatguy ,
Yaffle, just for my reference, does it matter if compareTo() returns -0?
Possibly, no. Although, if we want to have some standart...
negative zero is a result of "compareTo"