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

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

emo.eth pfp
emo.eth
@emo.eth
oooh this looks promising, lemme see what the opcodes work out to
1 reply
0 recast
0 reaction