Large numbers erroneously rounded in JavaScript
What you're seeing here is actually the effect of two roundings. Numbers in ECMAScript are internally represented double-precision floating-point. When id
is set to 714341252076979033
(0x9e9d9958274c359
in hex), it actually is assigned the nearest representable double-precision value, which is 714341252076979072
(0x9e9d9958274c380
). When you print out the value, it is being rounded to 15 significant decimal digits, which gives 14341252076979100
.
Prevent JavaScript Number function from rounding big numbers
JavaScript numbers are Double Precision Floats; the largest integer that can be precisely stored is 2^53 (9007199254740992).
If you actually need it in a number you have some fun math ahead of you, or you can use a library such as big.js
Related Topics
Why Does Changing an Array in JavaScript Affect Copies of the Array
How to Detect If Multiple Keys Are Pressed At Once Using JavaScript
Getting the Client'S Time Zone (And Offset) in JavaScript
Use Basic Authentication With Jquery and Ajax
What Is a Good Regular Expression to Match a Url
Async/Await Implicitly Returns Promise
Events Triggered by Dynamically Generated Element Are Not Captured by Event Handler
Rails 4: How to Use $(Document).Ready() With Turbo-Links
Get the Current Url With JavaScript
Jquery Animate Backgroundcolor
JavaScript: Natural Sort of Alphanumerical Strings
Attach Event to Dynamic Elements in JavaScript
What Is the Purpose of Node.Js Module.Exports and How to Use It
JavaScript For Detecting Browser Language Preference
How to Declare a Namespace in JavaScript
What Is the !! (Not Not) Operator in JavaScript