That's what I'm doing, rounding them. I wasn't really having a problem, so much as I wanted to know if anybody else was getting the same thing. I thought they probably would and that it was weird.
I discovered this because I have a complex script and batch file that generates from a csv file a printable data sheet for a client in the form of an HTML page that I can then attach to an email. Usually I just take the values as given in the text strings, but this time I need to subtract the previous balance of 165.52 to get the actual totals for this category of transaction.
I'm using:
Code:
money(Math.round((window[i][16]-165.52)*100)/100)
where window[i][16] represents the running balance with the previous balance included. My money() function is:
Code:
function money (n){
var c=n.toString(10).split('.')[1];
return n.toString(10)+(c&&c.length==2? '' : c&&c.length==1? '0' : '.00');
}
Seems to work out.
Notes: I only need this in FF, once I get the page in it, I use the Developer Extension to grab the generated source which is then cross browser. As a result, I've no idea (and don't need to) how cross browser any of the above code might or might not be.
Bookmarks