Replies: 1 comment
-
Commenting for posterity.
from z3 import *
import math
lookup = lambda x, l: (l >> ((31 - (x & 31)) << 3)) & 0xff
l = BitVec('l', 256)
q = BitVec('q', 256)
solve(*[lookup(q >> i, l) == int(math.log2(i)) if i != 0 else lookup(q >> i, l) == 0 for i in range(256)], q >> 128 == 0, l & 0xffffffff == 0)
from z3 import *
lookup = lambda x, q, l: (l >> ((31 - ((q / x if x > 0 else 0) & 31)) << 3)) & 0xff
l = BitVec('l', 256)
q = BitVec('q', 256)
solve(*[lookup(1 << i, q, l) == i for i in range(32)], lookup(0, q, l) == 0) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was looking at the
fls
function inLibBit
, and the last statement caught my attention:solady/src/utils/LibBit.sol
Lines 35 to 37 in 5d0198b
It would be helpful to provide an explainer comment above this line, so that readers of the contract know why you use 251, 224, and the other hardcoded values in this function.
Beta Was this translation helpful? Give feedback.
All reactions