Browse Source

fix rare infinite loop with floating point inaccuracies in Fraction.ts (#880)

In certain cases, b becomes very small (2.0e-14) and never converges to 0.
Dathan 4 years ago
parent
commit
669400125b
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/Common/DataObjects/Fraction.ts

+ 1 - 1
src/Common/DataObjects/Fraction.ts

@@ -64,7 +64,7 @@ export class Fraction {
       return 1;
       return 1;
     }
     }
 
 
-    while (b !== 0) {
+    while (Math.abs(b) > 0.0000001) {
       if (a > b) {
       if (a > b) {
         a -= b;
         a -= b;
       } else {
       } else {