The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hyperlane-monorepo/solidity/contracts/libs/LibBit.sol

27 lines
608 B

// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;
/// @notice Library for bit shifting and masking
library LibBit {
function setBit(
uint256 _value,
uint256 _index
) internal pure returns (uint256) {
return _value | (1 << _index);
}
function clearBit(
uint256 _value,
uint256 _index
) internal pure returns (uint256) {
return _value & ~(1 << _index);
}
function isBitSet(
uint256 _value,
uint256 _index
) internal pure returns (bool) {
return (_value >> _index) & 1 == 1;
}
}