an integer starting from bit lsb going to the left to 1?
For example width = 32 and lsb = 16 should result in 0b0000000000000000111111111111111111111111111111110000000000000000.
((2 ^ (width + 1)) - 1) << lsb
unsigned long wlset(unsigned width, unsigned lsb){ return ((1<<width)-1)<<lsb; }
Beware, there may be edge cases at the max value for width, you may want to handle that case specially
Обсуждают сегодня