You are viewing limited content. For full access, please sign in.

Question

Question

javascript not rounding to 2 decimal places

asked on February 25, 2015

i used the javascript from support section but for some reason it is not rounding to 2 decimal places when adding or multiplying fields.  can someone help me out with that?

0 0

Replies

replied on February 25, 2015

To display a number in javascript with a fixed number of decimal places use the Number.toFixed(n) method, where n is the required number of decimal places.

var operator1 = 1.2567;
var operator2 = 2.4534;
var total = (operator1 * operator2).toFixed(2);

 

1 0
replied on February 25, 2015

thanks that worked.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.