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
`Decimal.ceil` is incorrect for very small positive numbers #130
When Math.ceil is evaluated for a very small positive number, such as 1e-300, it returns 1, which is correct.
When Decimal.ceil is evaluated for the same small positive number, it returns 0 which is incorrect and inconsistent with Math.ceil.
When Math.ceil is evaluated for a very small negative number, such as -1e-300, it returns -0, which is correct and equal to 0.
When Decimal.ceil is evaluated for the same small negative number, it returns 0, which is correct.
Therefore, Decimal.ceil is incorrect for very small positive numbers, including but not limited to:
1e-16 // 1e-15 outputs the correct result of 1
1e-300
"1e-1000"
Decimal.recip("ee308")
Decimal.recip(Decimal.tetrate(10, Number.MAX_VALUE))
There is similar incorrect behavior for Decimal.floor with very small negative numbers:
When
Math.ceil
is evaluated for a very small positive number, such as1e-300
, it returns1
, which is correct. WhenDecimal.ceil
is evaluated for the same small positive number, it returns0
which is incorrect and inconsistent withMath.ceil
.When
Math.ceil
is evaluated for a very small negative number, such as-1e-300
, it returns-0
, which is correct and equal to0
. WhenDecimal.ceil
is evaluated for the same small negative number, it returns0
, which is correct.Therefore,
Decimal.ceil
is incorrect for very small positive numbers, including but not limited to:There is similar incorrect behavior for
Decimal.floor
with very small negative numbers: