I'm trying to implement a function in Solidity that checks if the bit at a position is set or not, i.e. I want a function like:
function isBitSet(bytes24 b, uint pos) returns (bool){
return ...
}
I tried to transfer this approach to Solidity: Checking if a bit is set or not
function isBitSet(bytes24 b, uint pos) returns (bool){
return (b & (1 << pos)) != 0;
}
However, this does not work because (1 << pos)
returns type uint256
...