08.08.2011, 15:54
How about this:
Instead of this:
pawn Код:
bitLim = ((1 << (1 << _: bitShift)) - 1)
//Case Bit1: (1 << (1 << 0) - 1 = (1 << 1) - 1 = 2 - 1 = 1 is correct!
//Case Bit2: (1 << (1 << 1) - 1 = (1 << 2) - 1 = 4 - 1 = 3 is correct!
//Case Bit4: (1 << (1 << 2) - 1 = (1 << 4) - 1 = 16 - 1 = 15 is correct!
//Case Bit8: (1 << (1 << 3) - 1 = (1 << 8) - 1 = 256 - 1 = 255 is correct!
//Case Bit16: (1 << (1 << 4) - 1 = (1 << 16) - 1 = 65536 - 1 = 65535 is correct!
//I had to test it because I wasn't sure 100% test.
//OK; Now I'm sure because a shift is a multiplication by 2. And 1 << x == 2 ^ x where ^ denotes power.
pawn Код:
bitLim = ((1 << floatround(floatpower(2.0, _: bitShift))) - 1)
