def _cbrt(n: uint256) -> uint256:
if (n > 84):
x: uint256 = n
y: uint256 = 1 << unsafe_add(unsafe_div(_snekmate_log_2(n, False), 3), 1)
while (x > y):
x = y
y = unsafe_div(unsafe_add(x << 1, unsafe_div(n, unsafe_mul(x, x))), 3)
return x
return 0x49249249249249246db6db6db6db6db6db6db6db6db692492492492492249248 >> unsafe_mul(n, 3) & 0x7
For the calculation of a cubic root, which is implemented in the math library of twocryptoswap and probably in a few other places, consider a simplified version which by and large performs the same number of operations (i.e., consumes the same amount of gas):