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
120 stars 43 forks source link

`new Decimal("(e^x)1")` returns `Decimal` with fractional `layer` if `x` is not an integer #166

Closed James103 closed 1 month ago

James103 commented 4 months ago

For example, new Decimal("(e^8.1)1") returns a Decimal whose layer is 6.1.

Similarly, new Decimal("(e^22.1)1") returns a Decimal whose layer is 20.1.

Both Decimal objects have invalid layer values and may not work properly with operations.

Fixing this may require the use of Decimal.tetrate in place of setting layer directly.

MathCookie17 commented 1 month ago

Fixed. toString (and thus new Decimal()) will now handle fractional e^N values.

normalize still doesn't work with fractional layers, though. This is because there are two different approximations for tetration and normalize won't know which one to use, whereas toString has a parameter that lets you choose which one (as with the rest of break_eternity, analytic is used by default when possible, the parameter can be used to force linear). I'm not sure what to do in this case. I'm closing the issue for now because the case you actually complained about is fixed - new Decimal should no longer be able to create Decimals with fractional layer - but feel free to re-open it if you think that fromComponents still possibly creating invalid Decimals is a problem.