From 89e9cb86e2ea049df6a9b382ebf766192dfd193e Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Wed, 26 Sep 2018 12:01:36 +0200 Subject: [PATCH] fixed according to pull request review --- vendor/assets/javascripts/ruleJS.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/vendor/assets/javascripts/ruleJS.js b/vendor/assets/javascripts/ruleJS.js index 952738671..ee71c423e 100644 --- a/vendor/assets/javascripts/ruleJS.js +++ b/vendor/assets/javascripts/ruleJS.js @@ -1038,10 +1038,10 @@ var ruleJS = (function (root) { //(sci-2587) MODIFICATION TO AVOID JAVASCRIPT IEEE MANTISSA&EXPONENT FLOATS INNACURACY try{ var number1_big = new Big(number1); - var result_big = number1_big.plus(number2) - result = parseFloat(result_big) + var result_big = number1_big.plus(number2); + result = parseFloat(result_big); } catch(e) { - result = number1 + number2 + result = number1 + number2; } //MODIFICATION END @@ -1051,24 +1051,23 @@ var ruleJS = (function (root) { //(sci-2587) MODIFICATION TO AVOID JAVASCRIPT IEEE MANTISSA&EXPONENT FLOATS INNACURACY try{ var number1_big = new Big(number1); - var result_big = number1_big.minus(number2) - result = parseFloat(result_big) + var result_big = number1_big.minus(number2); + result = parseFloat(result_big); } catch(e) { - result = number1 - number2 + result = number1 - number2; } //MODIFICATION END //ORIGINAL: result = number1 - number2; break; case '/': - //(sci-2587) MODIFICATION TO AVOID JAVASCRIPT IEEE MANTISSA&EXPONENT FLOATS INNACURACY try{ var number1_big = new Big(number1); - var result_big = number1_big.div(number2) - result = parseFloat(result_big) + var result_big = number1_big.div(number2); + result = parseFloat(result_big); } catch(e){ - result = number1 / number2 + result = number1 / number2; } //MODIFICATION END @@ -1081,14 +1080,13 @@ var ruleJS = (function (root) { } break; case '*': - //(sci-2587) MODIFICATION TO AVOID JAVASCRIPT IEEE MANTISSA&EXPONENT FLOATS INNACURACY try{ var number1_big = new Big(number1); - var result_big = number1_big.times(number2) - result = parseFloat(result_big) + var result_big = number1_big.times(number2); + result = parseFloat(result_big); } catch(e) { - result = number1 * number2 + result = number1 * number2; } //MODIFICATION END