Add a 0 to the end of a decimal number to make sure it's always 2 decimals?
Posted
by tarnfeld
on Stack Overflow
See other posts from Stack Overflow
or by tarnfeld
Published on 2010-04-15T12:20:42Z
Indexed on
2010/04/15
12:23 UTC
Read the original article
Hit count: 260
I am using the following code to work out an inc and ext VAT price:
$('#totalexvat').text(totalprice);
var vat = totalprice / 100 * 17.5;
vat = roundNumber(vat,2);
$('#totalincvat').text(totalprice-vat);
Sometimes i get .3 or .9 instead of what I would like to be .30 or .90 because it's money, is there a way to do this?
© Stack Overflow or respective owner