I came across this issue a while back when I was testing some HTML forms. The Maximum number of digits in JavaScript Number with a decimal point is only 16
I have tried the following
var x = 12345678912345.6789
x is 12345678912345.68 - 16 Digits only
var x = 123456789123.6789
x is 123456789123.6789 - 16 Digits only
new Number(12345678912345.6789)
12345678912345.68 - 16 Digits only
new Number(123456789123.6789)
123456789123.6789 - 16 Digits only
if you count the total digits, they are 16. If you increase digits before decimal point, the digits after decimal point get rounded
Similarly
new Number(.12345678912367890)
is 0.1234567891236789 - 16 Digits only (notice trailing 0 is missing)
Which makes me deduce that I can only have 16 Digits in a number with Decimal in it. If I try to add more digits, the number starts to round
I also observed that when I serialize a number with decimal into JSoN in ASP.NET MVC, it also converts the number to Max 16 Digits and rounds the rest
My Question: why?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…