• Post Reply Bookmark Topic Watch Topic
  • New Topic

parseFloat()

 
Sreejith kayappuram
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i want to parse a long float value.

document.write(parseFloat("9999999999999999"));
result = > 999999999999999


But if value is

document.write(parseFloat("99999999999999999"));

result = > 10000000000000000

is there any other way i can parse this long value ?
 
Joe Ess
Bartender
Posts: 9370
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be aware that floating-point numbers on computers are approximations, not exact values. This JDC Article has examples to illustrate the problem and a solution in Java.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!