Use size digits 2^k. To extract the digit nth:
#define BASE (2<<k)
#define MASK (BASE-1)
inline unsigned get_digit(unsigned word, int n) {
return (word >> (n*k)) & MASK;
}
Using a shift and mask (using a base which is a power of 2) avoids costly integer instructions.
- ( ). , k==3 ( 8) , k==4 ( 16) , . , , , , 32 64 . , , , .
: , , , . , , , radix , 1 0. , , , k .