Open zaryab2000 opened 1 year ago
Thanks for adding this! This is to show the 1 in
Get's ignored.
hey @jeffreyscholz ,
Just to be very sure, our aim is to mask the entire thing and only get the value stored in State variable E, correct?
If that's the case, we can AND this entire thing with just "0xf", isn't it?
e := and(0xffff, shifted)
Why do we need to SHOW the 1 in 0x0000000000000000000000000000000000000000000000000000000000010008
e
is a uint16 (2 bytes), so it is appropriate to use a mask with 2 bytes (0xFFFF). If e
happened to be a number that is larger than 255, then you would want to also capture the upper byte. Using only 0xFF would erase the top byte of e
.
The readE() function includes masking at the very end, to get the exact value of E state variable.
However, it uses 0xffff specifically, to mask the shifted value, while the same can be achieved using just 0xf.
https://github.com/RareSkills/Udemy-Yul-Code/blob/17aec03882dd951b0d15707d71b6ab38626d853c/Video-05-Storage-2.sol#L66
Questions