[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

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 ?
0
pcorreya
Asked:
pcorreya
1 Solution
 
jbirkCommented:
Math.round(num*10000)/10000

should do the trick for you.

-Josh
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now