Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




The JavaScript FAQ
Prev Home Next


Question: Sometimes JavaScript computations seem to yield "inaccurate" results, e.g. 0.362*100=36.199999999999996. How can I avoid this?

Answer: To avoid "inaccurate" results, you might want to round the results to the precision of the data you used. For example, in order to round the result to one thousandth, you can use this code:

roundedX = Math.round(1000*rawX)/1000; Copyright © 1999-2006, Alexei Kourbatov

The JavaScript FAQ
Prev Home Next

  Mirrored with kind permission of Alexei Kourbatov Design by Interspire