Module bithacks

Source
Expand description

Bithacks to minimise the cost

Functions§

highest_bit_set
bithacks functions. Implmented according to paper “Faster Remainder by Direct Computation Applications to Compilers and Software Libraries” Given a 32-bit number, find the highest bit number which is set 1. e.g:
round_up_to_power2
Given a 32-bit number, return the next highest power of 2, and the corresponding thift. e.g: