Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The normalization of new Decimal(-Infinity) breaks some operations and may be incorrect #168

Closed
James103 opened this issue Apr 26, 2024 · 3 comments

Comments

@James103
Copy link

new Decimal(Infinity) returns a Decimal object with { sign: 1, mag: Infinity, layer: Infinity }.
new Decimal(Infintiy).negate() returns a Decimal object with { sign: -1, mag: Infinity, layer: Infinity }.
Normalizing this with new Decimal(Infintiy).negate().normalize(), I get a Decimal object with { sign: -1, mag: -Infinity, layer: -Infinity }.
Running new Decimal(-Infinity) directly also returns a Decimal object with { sign: -1, mag: -Infinity, layer: -Infinity }.

Either the normalization of new Decimal(-Infinity) should be a Decimal object with { sign: -1, mag: Infinity, layer: Infinity }, or functions operating on Decimals should be changed to handle Decimals consisting of { sign: -1, mag: -Infinity, layer: -Infinity }.

Originally found in https://mathcookie17.github.io/Eternal-Notations/, by navigating to that page, opening a browser console for that page, and running the command formatAll(new Decimal(-Infinity)) there.

@MathCookie17
Copy link
Collaborator

MathCookie17 commented May 9, 2024

I am of the opinion that -Infinity should be {-1, Infinity, Infinity}, but break_eternity was designed with -Infinity as {-1, -Infinity, -Infinity}, so that's what it normalizes to - it just wasn't even registering as -Infinity as all when I had it normalizing to {-1, Infinity, Infinity}. I don't want to cause a breaking change, so despite my preferences, it'll remain as {-1, -Infinity, -Infinity}... so I'll probably need to make a bunch of special cases to fix it in the functions. I'll look into this at some point.

@MathCookie17
Copy link
Collaborator

I did an immediate fix for the Eternal Notations issue (i.e. it now detects infinities in a way that sidesteps the break_eternity bug, so -Infinity works there now. Figured I'd note this here since this was kind of an Eternal Notations issue too, though I haven't looked at the actual break_eternity bug yet)

@MathCookie17
Copy link
Collaborator

...on second thought, there are just too many strange cases that {-1, -Infinity, -Infinity} causes. I'm changing it to {-1, Infinity, Infinity} like it always should have been.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants