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

different results when expexting the same result #150

Open 1231234md5 opened 1 year ago

1231234md5 commented 1 year ago

I tried 'ee4e-1' and 'ee0.4' in break_eternity.min.js(call it BEm.js), I got the following results:

image

what the fuck is that? (in the representation of BEm.js, it is about 5.918804334257232e-317 and 325.0022978095479, 300+ OoMs' difference)

1231234md5 commented 1 year ago

break-eternity.js has the same problem

jakub791 commented 1 year ago

Just Why would someone use like ee0.4?

jakub791 commented 1 year ago

If we handled every possible notation like this one we'd surfer from performance issuses - parsing strings is already one of the slowest things in B_E

1231234md5 commented 1 year ago

What if some notation uses it?

MathCookie17 commented 4 months ago

This probably comes from the way break_eternity handles negative exponents in strings. To ensure that, say “(e^100)-1” can be written to mean the reciprocal of “(e^100)1” (because that’s more useful behavior than what it would do if interpreted “correctly” - if interpreted correctly, writing the reciprocal of “(e^100)1” would require writing “e-eeeee….1” with 99 e’s after the negative sign), break_eternity takes negative signs anywhere above the base of the power tower and assumes they’re meant to apply to the first (i.e. the lowest non-base) exponent of the tower.

…although, interpreted in that way, “ee4e-1” would mean “e-e40”, which should have mag -40 and layer 2…