From ec07d30f9354c535cb15ca4c20b3cac61f1080db Mon Sep 17 00:00:00 2001 From: Timothy Stiles Date: Sun, 21 Nov 2021 16:38:33 +1100 Subject: [PATCH] add a comment (to explain #52) --- dist/break_infinity.cjs.js | 1 + dist/break_infinity.esm.js | 1 + dist/break_infinity.js | 1 + src/index.ts | 2 ++ 4 files changed, 5 insertions(+) diff --git a/dist/break_infinity.cjs.js b/dist/break_infinity.cjs.js index 8ffe630..cd04d4b 100644 --- a/dist/break_infinity.cjs.js +++ b/dist/break_infinity.cjs.js @@ -651,6 +651,7 @@ function () { // But it's not clear how to specifically write that. // So I'll just settle with 'exponent >= 0 and difference between rounded // and not rounded < 1e-9' as a quick fix. + // UN-SAFETY: It still eventually fails. Since there's no way to know for sure we started with an integer, all we can do is decide what tradeoff we want between 'yeah I think this used to be an integer' and 'pfft, who needs THAT many decimal places tracked' by changing ROUND_TOLERANCE. https://github.com/Patashu/break_infinity.js/issues/52 Currently starts failing at 800002. Workaround is to do .Round() AFTER toNumber() if you are confident you started with an integer. // var result = this.m*Math.pow(10, this.e); if (!isFinite(this.e)) { return Number.NaN; diff --git a/dist/break_infinity.esm.js b/dist/break_infinity.esm.js index d08480a..3e13b21 100644 --- a/dist/break_infinity.esm.js +++ b/dist/break_infinity.esm.js @@ -645,6 +645,7 @@ function () { // But it's not clear how to specifically write that. // So I'll just settle with 'exponent >= 0 and difference between rounded // and not rounded < 1e-9' as a quick fix. + // UN-SAFETY: It still eventually fails. Since there's no way to know for sure we started with an integer, all we can do is decide what tradeoff we want between 'yeah I think this used to be an integer' and 'pfft, who needs THAT many decimal places tracked' by changing ROUND_TOLERANCE. https://github.com/Patashu/break_infinity.js/issues/52 Currently starts failing at 800002. Workaround is to do .Round() AFTER toNumber() if you are confident you started with an integer. // var result = this.m*Math.pow(10, this.e); if (!isFinite(this.e)) { return Number.NaN; diff --git a/dist/break_infinity.js b/dist/break_infinity.js index 4433fd9..eff6372 100644 --- a/dist/break_infinity.js +++ b/dist/break_infinity.js @@ -688,6 +688,7 @@ // But it's not clear how to specifically write that. // So I'll just settle with 'exponent >= 0 and difference between rounded // and not rounded < 1e-9' as a quick fix. + // UN-SAFETY: It still eventually fails. Since there's no way to know for sure we started with an integer, all we can do is decide what tradeoff we want between 'yeah I think this used to be an integer' and 'pfft, who needs THAT many decimal places tracked' by changing ROUND_TOLERANCE. https://github.com/Patashu/break_infinity.js/issues/52 Currently starts failing at 800002. Workaround is to do .Round() AFTER toNumber() if you are confident you started with an integer. // var result = this.m*Math.pow(10, this.e); if (!isFinite(this.e)) { return Number.NaN; diff --git a/src/index.ts b/src/index.ts index f75efee..b083312 100644 --- a/src/index.ts +++ b/src/index.ts @@ -683,6 +683,8 @@ export default class Decimal { // But it's not clear how to specifically write that. // So I'll just settle with 'exponent >= 0 and difference between rounded // and not rounded < 1e-9' as a quick fix. + + // UN-SAFETY: It still eventually fails. Since there's no way to know for sure we started with an integer, all we can do is decide what tradeoff we want between 'yeah I think this used to be an integer' and 'pfft, who needs THAT many decimal places tracked' by changing ROUND_TOLERANCE. https://github.com/Patashu/break_infinity.js/issues/52 Currently starts failing at 800002. Workaround is to do .Round() AFTER toNumber() if you are confident you started with an integer. // var result = this.m*Math.pow(10, this.e);