How do I expand the hexadecimal number 0x1234 to 0x11223344 in a high-performance way?
unsigned int c = 0x1234, b; b = (c & 0xff) << 4 | c & 0xf |
Perhaps this could be more simpler & efficient.
unsigned int g = 0x1234; unsigned int ans = 0; ans = ( ( g & 0xf000 ) << 16) + ( (g & 0xf00 ) << 12) + ( ( g&0xf0 ) << 8) + ( ( g&0xf ) << 4); ans = ( ans | ans>>4 ); printf("%p -> %p\n", g, ans);