About This Product
FontsMadeEasy.com
 
Search This Database:
| Over 5000 Free Fonts | Tutorials | Javascript Forum | Other Javascript Resources | Cheat Sheet
Tutorial archive
General Questions
Javascript 1.2
Navigation
Numbers
Strings
Object Model
Reference Manual
Dialog
Windows
Frames
Forms
Images
Mouse Events
Colors
File Access
Control Status Bar
Dates and Time
Cookies
Client Information
Bookmarklets


Accuracy

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;

BackBack