Problem with AW.Formats.Number
Hello, we are having some problems formatting numbers using AW.Formats.Number.
We want a format with 6 decimal positions, so we are using the following format:
It works fine most of the time, but when the value is 0, then the grid shows: 5e-7. We have traced the code and the problem seems to be in the function doFormat:
Any idea? Because our client only wants it with the format 0.000000
In addition, it is not only a matter of format, because if we send 5e-7, we are storing 0.0000005 which is not 0 (and for this application, precision is very important)
Thanks in advance,
José Luis.
We want a format with 6 decimal positions, so we are using the following format:
var decimal_6decFormat = new AW.Formats.Number;
decimal_6decFormat.setTextFormat("###.######");
It works fine most of the time, but when the value is 0, then the grid shows: 5e-7. We have traced the code and the problem seems to be in the function doFormat:
var doFormat = function(value){
var multiplier = this._multiplier;
var abs = (value<0) ? -value : value;
var delta = (value<0) ? -0.5 : +0.5;
var rounded = (Math.round(value * multiplier) + delta)/multiplier + "";
if (abs<1000) {return rounded.replace(this.p1, this.r1)}
if (abs<1000000) {return rounded.replace(this.p2, this.r2)}
if (abs<1000000000) {return rounded.replace(this.p3, this.r3)}
return rounded.replace(this.p4, this.r4);
};
Any idea? Because our client only wants it with the format 0.000000
In addition, it is not only a matter of format, because if we send 5e-7, we are storing 0.0000005 which is not 0 (and for this application, precision is very important)
Thanks in advance,
José Luis.
Jose Luis (Spain)
April 6,