infrastructure-upgrade/lib/v3-core/contracts/test/BitMathTest.sol
T-Hax 735546619e
init
Signed-off-by: T-Hax <>
2023-04-08 18:46:18 +00:00

27 lines
812 B
Solidity

// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
import '../libraries/BitMath.sol';
contract BitMathTest {
function mostSignificantBit(uint256 x) external pure returns (uint8 r) {
return BitMath.mostSignificantBit(x);
}
function getGasCostOfMostSignificantBit(uint256 x) external view returns (uint256) {
uint256 gasBefore = gasleft();
BitMath.mostSignificantBit(x);
return gasBefore - gasleft();
}
function leastSignificantBit(uint256 x) external pure returns (uint8 r) {
return BitMath.leastSignificantBit(x);
}
function getGasCostOfLeastSignificantBit(uint256 x) external view returns (uint256) {
uint256 gasBefore = gasleft();
BitMath.leastSignificantBit(x);
return gasBefore - gasleft();
}
}