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
121 stars 44 forks source link

Simplify Decimal constructor #91

Closed mcpower closed 2 years ago

mcpower commented 2 years ago

As fromNumber, fromString and fromDecimal are guaranteed to set sign, mag and layer, the initial values of sign, mag and layer (NaNs) are effectively unused.

As TypeScript compiles down default values to "immediately set default values at the start of the constructor", this commit replaces the default values of NaNs to 0s, which allows us to remove the value === undefined branch of the constructor.

Patashu commented 2 years ago

Great, undeniable improvement to me.