Skip to content

Instantly share code, notes, and snippets.

@aviggiano
Last active June 7, 2024 14:16
Show Gist options
  • Save aviggiano/7dfb233ccfe75f14d4d6a39a2bbcb2bc to your computer and use it in GitHub Desktop.
Save aviggiano/7dfb233ccfe75f14d4d6a39a2bbcb2bc to your computer and use it in GitHub Desktop.
IMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface IMath {
/// @notice Find the index of `value` in the sorted list `array`
/// @dev If `value` is below the lowest value in `array` or above the highest
/// value in `array`, the function returns
/// (type(uint256).max, type(uint256).max)
/// @param array The sorted list to search
/// @param value The value to search for
/// @return low The index of the largest element in `array` that is less than
/// or equal to `value`
/// @return high The index of the smallest element in `array` that is greater than
/// or equal to `value`
function binarySearch(uint256[] memory array, uint256 value) external
pure returns (uint256 low, uint256 high);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment