Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fallback to native rounding if newer approach fails
Browse files Browse the repository at this point in the history
Tom Groves committed May 29, 2018
1 parent b62b1b1 commit e264007
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bits/60_number.js
Original file line number Diff line number Diff line change
@@ -63,6 +63,10 @@ function rnd(val/*:number*/, d/*:number*/)/*:string*/ {
}
result = +(Math.round(+arr[0] + "e" + sig + (+arr[1] + d)) + "e-" + d);
}
if (isNaN(result)) {
var dd = Math.pow(10, d);
result = Math.round(val * dd) / dd;
}
return "" + result
}
function dec(val/*:number*/, d/*:number*/)/*:number*/ {

0 comments on commit e264007

Please sign in to comment.