I am having trouble when I display certain values on my chart that have huge strings of decimal numbers. It happens with Russel (730.80000000000001), Gas, Oil, but not with FTSE or DAX, or DOW. Please see PICS below. I can not find and EFS function to strip off decimal places. Math. ROUND is not what I want since I do not want to round to the next interger.
Announcement
Collapse
No announcement yet.
Annoying Decimals
Collapse
X
-
Perhaps this function will be helpful to you.
We use it for formatting the prices on the currencies we trade but you should be able to adjust it as needed (just change the value of dmax). It even has error checking.
It returns your passed value (fnum) as a properly formatted float:
PHP Code:function fixFloat(fnum) {
var dmax = 4;
var outnum;
if (isNaN(fnum) || fnum == null) {
return(null);
} else {
outnum = fnum.toFixed(dmax);
outnum = parseFloat(outnum);
return(outnum);
}
}
Good luck
-t
Comment
Comment