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

Fix #41: Handle large numbers safely in millify using BigInt #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

baraich
Copy link

@baraich baraich commented Sep 30, 2024

Problem:

The millify library throws a warning when the input value exceeds JavaScript’s safe integer range (-(2^53 - 1) to (2^53 - 1)), causing incorrect behavior when trying to format large numbers such as 210000000000000000.

Changes:

  • Added a new safeMillify function that:
    • Converts large numbers to BigInt.
    • Scales down numbers outside the safe range.
    • Passes the scaled number to millify for formatting.
    • Reapplies the original scale after millification.

Note

I have replaced the default millify function with safeMillify, though it is exported as the same name. Should we consider exporting safeMillify seperately?

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

Successfully merging this pull request may close these issues.

1 participant