Wednesday, 15 April 2015

javascript - how to get a float using parseFloat(0.00) -



javascript - how to get a float using parseFloat(0.00) -

how can float of 0.00. reason need 0.00, because going accumalating float values adding. hence starting 0.00. tried

var tmp ='0.00' tmp = parsefloat(tmp.tostring()).tofixed(2); totals = parsefloat(tmp)

tmp 0.00 totals 0. how can create total 0.00? need remain float , not string. thanks

you can utilize string tmp variable , when need add together use:

tmp = (+tmp + 8).tofixed(2);

jsfiddle demo

or write function seeing you'll have many times:

function stradd( tmp, num ) { homecoming (+tmp + num).tofixed(2); }

javascript jquery

No comments:

Post a Comment