Suppose I have an increasing sequence of unsigned integers C[i]. As they grow, they will probably occupy more and more bits. I am looking for an efficient conditional system based solely on two consecutive elements of a sequence C[i]and C[i+1](past and future are not observed) that will be evaluated as true or approximately once every time the number of bits required.
The obvious (but slow) choice of the conditional is:
if (ceil(log(C[i+1])) > ceil(log(C[i]))) ...
as well as anything that calculates the number of leading zero bits using special cpu opcodes (much better, but still not very).
I suspect there might be a good solution involving an expression using only the bitwise and / or bitwise value, as well as the C[i+1]and values C[i]. Any thoughts?
source
share