math - How do you round a two decimal places in Javascript? -
math - How do you round a two decimal places in Javascript? -
i trying round number 2 decemals , giving me integers!
var 4 = 10.99 + 89.78899999 total = number(a) + number(b);
here have:
math.round(total, 2); // gives me 101 need show 100.78
what trick this?
you should utilize tofixed(2)
with:
alert(12.432432.tofixed(2)); // 12.43
math.round
for: "returns value of number rounded nearest integer."
btw, 4
isn't valid variable name in javascript, can't begin number.
valid characters javascript variable names
javascript math decimal
Comments
Post a Comment