1e65e5057ec2295ca96a43c04e1716fe9029cdde
[platform/framework/web/crosswalk-tizen.git] /
1 define(['../lang/toNumber'], function(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     return enforcePrecision;
12 });