diff options
-rw-r--r-- | lib/decmath.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/decmath.js b/lib/decmath.js index ad79ec5..98c33e5 100644 --- a/lib/decmath.js +++ b/lib/decmath.js @@ -112,9 +112,20 @@ function drhfz(a, p) return as.substr(0, as.length - p) + "." + as.substr(as.length - p); } +function dfmt(a, p) +{ + a = a.toString().split(".", 2); + if (a.length == 1) return null; + if (a[0] == "") a[0] = "0"; + if (a[0] == "-") a[0] = "-0"; + if (a[1].length < p) a[1] += Array(p - a[1].length + 1).join("0"); + return a.join("."); +} + if (typeof global != "undefined") { global.dadd = dadd; global.dmul = dmul; global.drhtz = drhtz; global.drhfz = drhfz; + global.dfmt = dfmt; } |