How do I truncate a floating point number

I am currently using some script to add up numeric values in fields on the form to give a total. Example the values I use in the fields are .0031 + .0091 + .0080 and I get the total 0.020200000000. I would like the total to be truncated to 4 decimal places. How can this be done ?
LVL 1
pcorreyaAsked:
Who is Participating?
 
jbirkConnect With a Mentor Commented:
Math.round(num*10000)/10000

should do the trick for you.

-Josh
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.