Re: bitwise operations limited to 32 bits
- Posted by petelomax May 03, 2010
- 1404 views
DerekParnell said...
petelomax said...
... but the same is not true for or_bits, xor_bits, and not_bits.
Why?
Because code such as
function setBit(atom mask, integer bit) return or_bits(mask,power(2,bit-1)) end function atom mask mask = setBit(0,35)
will now fail silently, leaving mask 0.
Of course the literal 35 makes this a bit blatent, but what if it is an enum, so your code works fine until you insert a few more flags?
As I said, there is a strong case for and_bits(<anything>,#FFFFFFFF) to return the perfectly valid answer, but are there any real-world or_bits etc examples that I am missing whereby it should quietly and incorrectly set the top bits of the input to 0s?
Regards, Pete