fn computeInvPow5(i: u32) [4]u64 i: u32659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674 fn computeInvPow5(i: u32) [4]u64 {
const base = (i + FLOAT128_POW5_TABLE_SIZE - 1) / FLOAT128_POW5_TABLE_SIZE;
const base2 = base * FLOAT128_POW5_TABLE_SIZE;
const mul = &FLOAT128_POW5_INV_SPLIT[base]; // 1 / 5^base2
if (i == base2) {
return .{ mul[0] + 1, mul[1], mul[2], mul[3] };
} else {
const offset = base2 - i;
const m = &FLOAT128_POW5_TABLE[offset]; // 5^offset
const delta = pow5Bits(base2) - pow5Bits(i);
const shift: u6 = @intCast(2 * (i % 32));
const corr: u32 = @intCast(((FLOAT128_POW5_INV_ERRORS[i / 32] >> shift) & 3) + 1);
return mul_128_256_shift(m, mul, delta, corr);
}
}