Fit.UI
Fit.UI copied to clipboard
Allow number formatting using thousand separator
We need to be able to format numbers with both decimal and thousand separators.
Perhaps something like this.
function format(int)
{
var negative = (int < 0);
var val = Math.abs(int) + "";
var skipLength = val.length % 3;
var preVal = val.substring(0, skipLength);
val = val.substring(skipLength);
val = preVal + val.replace(/(\d{3})/g, ".$1");
if (val.indexOf(".") === 0)
val = val.substring(1);
if (negative)
val = "-" + val;
return val;
}