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

Wrong String for reciprocals #161

Open hypcos opened 5 months ago

hypcos commented 5 months ago

Input: Decimal.pow10(9996).pow10().recip()+'' Expect: 'e-e9996' Output: 'ee-9996.000000000005'

This is VERY wrong. ee-X means 10^(10^(-X)), which is not the reciprocal of 10^10^X, instead it is a number just a little bit bigger than 1. e-eX (with big X) means 10^(-(10^X)), which is the reciprocal of 10^10^X.

MathCookie17 commented 4 months ago

This is not a bug - at least, I don’t think it is. Interpreted correctly, “ee-9996” would just be 1, as it’s so close to 1 that break_eternity wouldn’t be able to tell the difference. As such, this string is kinda useless. On the other hand, if we wanted the reciprocal of 10^^10, it would be very annoying to have to type “e-eeeeeeee10” with the negative sign specifically after the first one. Therefore, the way break_eternity handles negative exponents, a negative sign anywhere in the power tower is treated as if it’s on the first exponent, since negatives higher in the power tower aren’t useful. This lets you write “(e^10)-1” to mean the reciprocal of “(e^10)1”, which is more useful than what it would be if interpreted correctly. Yes, this means “ee-9996” is interpreted as “e-e9996”, but that’s intended behavior.