Allow the use of Formater without additional processing of numbers.

precision >= 16 will output numbers as is.
This commit is contained in:
Jürg Lehni 2016-01-07 18:51:30 +01:00
parent 36a98706b3
commit d1e4807c6a

View file

@ -32,8 +32,11 @@ var Formatter = Base.extend(/** @lends Formatter# */{
*/
number: function(val) {
// It would be nice to use Number#toFixed() instead, but it pads with 0,
// unecessarily consuming space.
return Math.round(val * this.multiplier) / this.multiplier;
// unnecessarily consuming space.
// If precision is >= 16, don't do anything at all, since that appears
// to be the limit of the precision (it actually varies).
return this.precision < 16
? Math.round(val * this.multiplier) / this.multiplier : val;
},
pair: function(val1, val2, separator) {