I want to define a byte256 and I want to assign different sections of the byte to different variables, any literature or guidance is appreciated.
for further clarity I want to do something like
variable 0 = address
variable 1 = address
variable 2 = value
variable 3 = address
variable 5 = address
variable 4 = address
now Id want to do:
byte50:
bit 0-10= variable 0
bit 10-20= variable 1
bit 20-30= variable 2
bit 30-40= variable 3
bit 40-50= variable 4
I realize the above may not be correct at all(I'm just trying to give you an idea of what I'm trying to achieve). I would like to know firstly whether its feasible and if so how I should go on about it.
I have no idea how to handle this so I'd appreciate any pointers
uint8
variables in anuint16
one. Let-s denote these variablesx_1
,x_2
andx_all
, respectively.x_all = x_1 << 8 + x_2
(It is equivalent tox_all = x_1 * (2**8) + x_2
(N.B. an address in Ethereum is a 160-bit (20 bytes) length variable). In this question you can find something similar with riight shift operator ethereum.stackexchange.com/questions/61826/…