Reputation: 156
I'm using method "Ext.util.Format.number" to convert a value to string, according to a specific format. But this method add extra (parasite) decimal.
With this code :
var strValue = Ext.util.Format.number(value, this.displayFormat);
For example if
After conversion, strValue is not equals to 102.15 but to 102.15000000000001
Is there any way to be sure that "Ext.util.Format.number" never add extra/parasite decimal ?
Thanks
Upvotes: 1
Views: 676
Reputation: 36987
Since 102.15 and 102.15000000000001 are not distinguishable(*) in JavaScript, it's up to you to choose a number format that does not include that many digits. Ext.util.Format.number
has no way to determine the correct output.
(*) try 102.15 === 102.15000000000001
in your javascript console - it returns true
Upvotes: 1
Reputation: 266
Do parseFloat(strValue) after that formatting. I think thats what you are looking for.
Upvotes: 0