Consider 8 digit characters like 12345678 as a string. It can be converted to a number where every byte contains a digit like this:
const char* const str = "12345678";
const char* const base = "00000000";
const uint64_t unpacked = *reinterpret_cast<const uint64_t*>(str)
- *reinterpret_cast<const uint64_t*>(base);
Then unpacked will be 0x0807060504030201 on a little-endian system.
What is the fastest way to convert the number into 12345678, perhaps by multiplying it by some magic number or using SIMD up to AVX2?
UPDATE: 12345678 has to be a number stored in a 32-bit or 64-bit integer, not a string.