Module bithacks

Source
Expand description

Bithacks to minimise the cost bithacks functions.

Implemented according to paper “Faster Remainder by Direct Computation Applications to Compilers and Software Libraries”.

Functions§

highest_bit_set
Given a 32-bit number, find the highest bit number which is set 1.
round_up_to_power2
Given a 32-bit number, return the next highest power of 2, and the corresponding shift.