浏览代码

sub: fixed carry bug

Bernadette Elena Hammerle 2 年之前
父节点
当前提交
dfcfb45084
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      src/Subtraction.js

+ 3 - 0
src/Subtraction.js

@@ -361,6 +361,9 @@ function Subtraction() {
         text += " + " + carries[idxCarry]; // + " Übertrag"
       }
       let realCarry = Math.abs(parseInt(realDigitRes/10));
+      if(firstDigit !== 0 && realDigitRes % 10 === 0){
+        realCarry -= 1;
+      }
       realDigitRes = ((firstDigit - realDigitRes) % 10);
 
       if(realDigitRes < 0){