Content pfp
Content
@
0 reply
0 recast
2 reactions

emo.eth pfp
emo.eth
@emo.eth
is there a “magic number” solution to flipping a (uint32) number’s endianness? or is masking and shifting each byte always the best way? cc @optimizoor
2 replies
1 recast
2 reactions

Vectorized pfp
Vectorized
@optimizoor
Very good question. I just recalled I had this problem I’ve yet to solve.
0 reply
0 recast
1 reaction

frangio pfp
frangio
@frangio
According to Hacker's Delight, it doesn't look like there's an arithmetic solution. It proposes using a rotating shift that we can emulate in the EVM by first duplicating the number to 64 bytes using MUL. This should be better than masking and shifting each byte separately. In principle this should cost 41 gas.
1 reply
0 recast
2 reactions