I have a piece of code that is pulling data from a SharePoint list from I'm using SPServices and this code then pulls from the Spent column and adds up all the numbers and then puts it in an array however I'm getting some weird results.
none of the numbers it pulls through have more than 2 decimal places(it's a finance column) however I'm getting totals like 57062.229999999996 and 151704.58000000002
I've tried using .toFixed(2) on to mynumber and parseFloat(SpentFix) and then converting back to a number and I get the same results.
Also the reason why I have a .substring(7) is because the spend column is a computed field so when pulling data float,# is a the start of each entry for some reason
if anyone can help that would be great.
var SpentFix = $(this).attr("ows_Spent").substring(7);
if (SpentFix != undefined) {
var mynumber = parseFloat(SpentFix)
SLarray[counter][1] += mynumber;
}