3d3b2d409032a6543109f81b4d5fc776350a3d72
[platform/framework/web/crosswalk-tizen.git] /
1 var toNumber = require('../lang/toNumber');
2     /**
3      * Enforce a specific amount of decimal digits and also fix floating
4      * point rounding issues.
5      */
6     function enforcePrecision(val, nDecimalDigits){
7         val = toNumber(val);
8         var pow = Math.pow(10, nDecimalDigits);
9         return +(Math.round(val * pow) / pow).toFixed(nDecimalDigits);
10     }
11     module.exports = enforcePrecision;
12