How can I get a float of 0.00. The reason I need 0.00, is because I am going to be accumalating float values by adding. Hence starting with 0.00. I tried
var tmp ='0.00'
tmp = parseFloat(tmp.toString()).toFixed(2);
totals = parseFloat(tmp)
tmp is 0.00 but totals is 0. How can I make total 0.00? I need it to stay as a float and not a string. Thanks
You can use the string tmp
variable and then when you need to add to it use:
tmp = (+tmp + 8).toFixed(2);
JSFIDDLE DEMO
Or simply write a function to do that seeing that you'll have to do that many times:
function strAdd( tmp, num ) {
return (+tmp + num).toFixed(2);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With