From acdf89ec5458b94d5c575e569f7fda9b48ab53bb Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Sat, 18 Feb 2017 09:28:43 -0800 Subject: [PATCH] Make Int36 toDecimal() more paranoid (we want perfect output, or no output at all) --- modules/shared/lib/int36.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/shared/lib/int36.js b/modules/shared/lib/int36.js index c531a93fa..119441c1d 100644 --- a/modules/shared/lib/int36.js +++ b/modules/shared/lib/int36.js @@ -240,15 +240,15 @@ class Int36 { i36Tmp.negate(); fNeg = true; } - + /* + * Conversion of any 72-bit value should take no more than 3 divisions by 10,000,000,000. + */ var nMaxDivs = 3; do { i36Tmp.div(i36Div); /* - * In a perfect world, there would be no errors, because all Int36 calculations at - * this point should be positive values, the remainder should always be less than the - * divisor, and the entire process should complete within 3 divisions. But until then, - * let's make sure we don't produce garbage or spin our wheels. + * In a perfect world, there would be no errors, because all calculations at this point + * are within known bounds. But let's make sure we don't produce garbage or spin our wheels. */ if (i36Tmp.error || i36Tmp.remainder >= 10000000000 || !nMaxDivs--) { s = "error";