Signed-off-by: T-Hax <>
This commit is contained in:
T-Hax 2023-04-08 18:46:18 +00:00
commit 735546619e
No known key found for this signature in database
828 changed files with 222925 additions and 0 deletions

View file

@ -0,0 +1,26 @@
// 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();
}
}