Patashu / break_infinity.js

A replacement for decimal.js for incremental games who want to deal with very large numbers (bigger in magnitude than 1e308, up to as much as 1e(9e15) ) and want to prioritize speed over accuracy.
MIT License
203 stars 35 forks source link

cube root is sometimes inaccurate #142

Closed dan-simon closed 2 years ago

dan-simon commented 2 years ago

When trying to implement the cubic formula, I came across this problem:

c = new Decimal(2.5e-8)
Decimal {mantissa: 2.5, exponent: -8}
c.cbrt().pow(3)
Decimal {mantissa: 2.4999999999999996, exponent: -7}

(The cube root is inaccurate, not the .pow(3))