3 ms·
> how easily this could be extended to 64 bit integers? It's effectively: size_t logx = int_log2(x); uint32_t carry = ((uint64_t)x + tablo[logx]) >> 32;
by a1369209993 5y ago
> how easily this could be extended to 64 bit integers?
It's effectively:
size_t logx = int_log2(x);
uint32_t carry = ((uint64_t)x + tablo[logx]) >> 32;
return tabhi[logx] + carry;
Assembly can do (from a equivalent start):
mov rdx rax # save x
xor eax eax
add rdx [8*rcx+tablo] # set carry (would cmp be better?)
adc al [1*rcx+tabhi] # result never exceeds 64/log(10) < 20