Patashu / break_eternity.js

A Javascript numerical library to represent numbers as large as 10^^1e308 and as small as 10^-10^^1e308. Sequel to break_infinity.js, designed for incremental games.
MIT License
122 stars 46 forks source link

Subtract breaks with layer(s) #35

Closed Gniller closed 5 years ago

Gniller commented 5 years ago

new Decimal("ee17").minus(new Decimal("ee18")).toString() returns "ee17" - incorrect new Decimal("ee17").minus(new Decimal("eeee17")).toString() returns "ee17" - incorrect new Decimal("ee15").minus(new Decimal("ee16")).toString() returns "1e1000000000000000" - incorrect new Decimal("e15").minus(new Decimal("e16")).toString() returns "-9.000000000000007e16" - correct

Gniller commented 5 years ago

At these numbers, subtract is really only used to check if a numbers gets below zero. So technically just returning the correct sign should do the trick for all use cases I can currently think of.

I personally use it for combat. health - damage = currenthealth. If below 0, the unit died. So if ee17 - ee18 was to return -ee17 instead of ee17, that would already do the trick.

Patashu commented 5 years ago

Thanks for your report!