Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Well, I was bored and wanted to make code as simple and fast as possible. By casting to unsigned* it adds '0's and copies the whole sequence (4 digits) in single-word instructions. Neither memcpy nor a custom loop generates such clean assembly (try it yourself on godbolt :).
But it actually works! Can I ask about your solution?
Why do you use here your interesting type punning macro instead of memcpy() like this?:
memcpy (&ph[1], &nums[0], 4);
memcpy (&ph[6], &nums[3], 4);
memcpy (&ph[10],&nums[6], 4);
C standard doesn't guarantee any function argument evaluation order so theoretically this code is undef behavior, although in practice not sure if there is a compiler that wouldn't evaluate the above left to right;