From af7ae958d558f5b4281d76a7c10dd1f551e5be27 Mon Sep 17 00:00:00 2001 From: Tom Groves Date: Tue, 15 May 2018 10:34:27 +0100 Subject: [PATCH] introduce fix for issue 1105 (https://github.com/SheetJS/js-xlsx/issues/1105) --- bits/10_ssf.js | 2 +- xlsx.flow.js | 2 +- xlsx.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bits/10_ssf.js b/bits/10_ssf.js index c9cedb9..f180d78 100644 --- a/bits/10_ssf.js +++ b/bits/10_ssf.js @@ -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; diff --git a/xlsx.flow.js b/xlsx.flow.js index fa3203c..89a6be0 100644 --- a/xlsx.flow.js +++ b/xlsx.flow.js @@ -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; diff --git a/xlsx.js b/xlsx.js index 36c9c78..7423768 100644 --- a/xlsx.js +++ b/xlsx.js @@ -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;