Skip to content

Commit e264007

Browse files
author
Tom Groves
committed
fallback to native rounding if newer approach fails
1 parent b62b1b1 commit e264007

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

bits/60_number.js

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ function rnd(val/*:number*/, d/*:number*/)/*:string*/ {
6363
}
6464
result = +(Math.round(+arr[0] + "e" + sig + (+arr[1] + d)) + "e-" + d);
6565
}
66+
if (isNaN(result)) {
67+
var dd = Math.pow(10, d);
68+
result = Math.round(val * dd) / dd;
69+
}
6670
return "" + result
6771
}
6872
function dec(val/*:number*/, d/*:number*/)/*:number*/ {

0 commit comments

Comments
 (0)