bitwise operations limited to 32 bits
- Posted by petelomax May 03, 2010
- 1410 views
Someone has ripped out the above error, but I fear they have been a little over-zealous. I fully agree that and_bits() with either parameter 32 bits or less needed to be changed, but the same is not true for or_bits, xor_bits, and not_bits.
constant nines = #999999999, -- more than 32 bits f32 = #FFFFFFFF, m1 = -1 printf(1,"%08x\n",and_bits(nines,f32)) -- OK printf(1,"%08x\n",and_bits(nines,m1)) -- OK printf(1,"%08x\n",and_bits(nines,nines)) -- should crash printf(1,"%08x\n",or_bits(nines,f32)) -- should crash printf(1,"%08x\n",or_bits(nines,m1)) -- should crash printf(1,"%08x\n",or_bits(nines,nines)) -- should crash printf(1,"%08x\n",xor_bits(nines,f32)) -- should crash printf(1,"%08x\n",xor_bits(nines,m1)) -- should crash printf(1,"%08x\n",xor_bits(nines,nines)) -- should crash printf(1,"%08x\n",not_bits(f32)) -- OK printf(1,"%08x\n",not_bits(m1)) -- OK printf(1,"%08x\n",not_bits(nines)) -- should crash