introduce fix for issue 1105 (https://github.com/SheetJS/js-xlsx/issu… #1107

Open
tom-groves wants to merge 1 commits from tom-groves/bug-1105/rounding-error into master
3 changed files with 3 additions and 3 deletions

@ -310,7 +310,7 @@ function hashq(str/*:string*/)/*:string*/ {
}
return o;
}
function rnd(val/*:number*/, d/*:number*/)/*:string*/ { var dd = Math.pow(10,d); return ""+(Math.round(val * dd)/dd); }
function rnd(val/*:number*/, d/*:number*/)/*:string*/ { return ""+(+(Math.round(val + "e+" + d) + "e-" + d)); }
function dec(val/*:number*/, d/*:number*/)/*:number*/ {
if (d < ('' + Math.round((val-Math.floor(val))*Math.pow(10,d))).length) {
return 0;

@ -506,7 +506,7 @@ function hashq(str/*:string*/)/*:string*/ {
}
return o;
}
function rnd(val/*:number*/, d/*:number*/)/*:string*/ { var dd = Math.pow(10,d); return ""+(Math.round(val * dd)/dd); }
function rnd(val/*:number*/, d/*:number*/)/*:string*/ { return ""+(+(Math.round(val + "e+" + d) + "e-" + d)); }
function dec(val/*:number*/, d/*:number*/)/*:number*/ {
if (d < ('' + Math.round((val-Math.floor(val))*Math.pow(10,d))).length) {
return 0;

2
xlsx.js generated

@ -481,7 +481,7 @@ function hashq(str) {
}
return o;
}
function rnd(val, d) { var dd = Math.pow(10,d); return ""+(Math.round(val * dd)/dd); }
function rnd(val, d) { return ""+(+(Math.round(val + "e+" + d) + "e-" + d)); }
function dec(val, d) {
if (d < ('' + Math.round((val-Math.floor(val))*Math.pow(10,d))).length) {
return 0;