diff --git a/app/src/main/java/de/uni_marburg/powersort/FinnSort/FasterFinnSort.java b/app/src/main/java/de/uni_marburg/powersort/FinnSort/FasterFinnSort.java index 1f7dc8f..650ed97 100644 --- a/app/src/main/java/de/uni_marburg/powersort/FinnSort/FasterFinnSort.java +++ b/app/src/main/java/de/uni_marburg/powersort/FinnSort/FasterFinnSort.java @@ -459,13 +459,22 @@ public class FasterFinnSort { int n_1 = this.runLen[stackSize - 1]; int n_2 = this.runLen[stackSize]; - double a = ((double) this.runBase[stackSize - 1] + 0.5d * n_1 - 1d) / rangeSize; - double b = ((double) this.runBase[stackSize] + 0.5d * n_2 - 1d) / rangeSize; - int l = 0; - while ((int) (a * pow(2, l)) == (int) (b * pow(2 ,l))) { - l++; + + int a = 2 * this.runBase[stackSize - 1] + n_1; + int b = a + n_1 + n_2; + + int result = 0; + + while (b < rangeSize) { + ++result; + if (a >= rangeSize) { + a -= rangeSize; + b -= rangeSize; + } + a <<= 1; + b <<= 1; } - return l; + return result; } /*