Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Number in Javascript changes after declaring it as a variable. Even parsing it from a string returns a wrong number

This is very weird please check it yourself.

Whenever I try to declare variable with the number 76561198322368902 it always changes to 76561198322368900 no matter what.
Chrome Devtools Console Screenshot

Even when I pass the variable as a string and later parse to a number, it always changes to 76561198322368900.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I really don’t know what to do. I never thought Integers were capable of such thing.

>Solution :

The "maximum safe integer" in JavaScript is 9007199254740991 – trying to use the number type beyond this can yield unpredictable results.

Use the BigInt type if you need a bigger number.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading