Naruyoko / OmegaNum.js

A huge number library holding up to 10{1000}9e15. A basement for planned {10,x,1,2}.
https://naruyoko.github.io/OmegaNum.js/index.html
MIT License
33 stars 15 forks source link

cmp is incorrect for negative numbers #3

Closed Patashu closed 5 years ago

Patashu commented 5 years ago
new OmegaNum(-1).cmp(new OmegaNum(-2))
-1

(should be 1 since -1 > -2)

to fix this, you just have to multiply the return value by the sign if the signs are different, e.g. https://github.com/Patashu/break_eternity.js/blob/master/break_eternity.js#L1456

Naruyoko commented 5 years ago

α 1.0.1

Patashu commented 5 years ago

Not fixed, now I get this instead:

new OmegaNum(-1).cmp(new OmegaNum(-2))
OmegaNum.html:129 Uncaught TypeError: this.neg(...).cmp(...).neg is not a function
    at OmegaNum.P.compareTo.P.cmp (OmegaNum.html:129)
    at <anonymous>:1:18
Naruyoko commented 5 years ago

Facepalm Of course it doesn't work, I'm neg()ing on a Number!

Naruyoko commented 5 years ago

α 1.0.1.1

Patashu commented 5 years ago

Fixed!