Updated the power function to use integers

This commit is contained in:
finnm 2025-01-10 14:35:15 +01:00
parent 88f8df3c07
commit 2b85e4e956

View File

@ -459,13 +459,22 @@ public class FasterFinnSort<T> {
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;
}
return l;
a <<= 1;
b <<= 1;
}
return result;
}
/*