Skip to content

Instantly share code, notes, and snippets.

// Efficient SQRT method
// Constant gas cost of 293 discounting RETURN and CALLDATALOAD logic, or 311 including everything.
//
// Special thanks to @caironeth for have found a better log2(x) here:
// - https://github.com/Lohann/openzeppelin-contracts/pull/1
//
// For testing use this tool: https://www.evm.codes/playground?fork=cancun
// Authors:
// - Lohann Paterno Coutinho Ferreira <[email protected]>
// - Cairo <https://github.com/cairoeth>