Skip to content

dec to hex does not work for large integers #390

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

Open
bladepan opened this issue Apr 1, 2025 · 0 comments
Open

dec to hex does not work for large integers #390

bladepan opened this issue Apr 1, 2025 · 0 comments

Comments

@bladepan
Copy link

bladepan commented Apr 1, 2025

test case
120222480553230655 and 120222480553230660 produces the same hex string result. this is because https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER.
these 2 integers are still in 64bit integer range, so it is a common use case.

> parseInt('120222480553230655').toString(16)
'1ab1db587644140'
> parseInt('120222480553230660').toString(16)
'1ab1db587644140'

> BigInt('120222480553230655').toString(16)
'1ab1db58764413f'
> BigInt('120222480553230660').toString(16)
'1ab1db587644144'
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

1 participant