~31 is not a very nice way to write clear the lowest 5 bits. I personally would write &= 0x1F. The hex representation here is more obvious than 31.