Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
proposal: Add functions to convert between uints and byte arrays #39078
I propose adding functions to convert between uints and byte arrays of the same size. At a minimum, two new functions to convert between uint64 and byte. For symmetry, there can be functions to convert between uint32 and byte, and between uint16 and byte. These functions would go into math/bits.
The implementation can be inlined and compiled down to a single word copy. It is essentially a type cast.
already compiles to just 2 instructions (2 MOVQ, from the input stack slot to a register, and from the register to the output stack slot).