diff --git a/contracts/BytesLib.sol b/contracts/BytesLib.sol index 532897a..0f2b3a7 100644 --- a/contracts/BytesLib.sol +++ b/contracts/BytesLib.sol @@ -326,6 +326,17 @@ library BytesLib { return tempUint; } + + function toUint24(bytes memory _bytes, uint256 _start) internal pure returns (uint24) { + require(_bytes.length >= _start + 3, "toUint24_outOfBounds"); + uint16 tempUint; + + assembly { + tempUint := mload(add(add(_bytes, 0x3), _start)) + } + + return tempUint; + } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds");