Comment Comment by wholesomepotato it's one XOR, SHL, OR, SHR, AND, on some archs the shifts might come free with the other instruction. I'd expect it to be faster.a = v ^ 0x30303030lu // normalize to digits 0xXX0a0b0cb = (a << 12) | a // combine into XXXXXbacb0cidx = (b >> 12) & 0xfff // get bacres = lookup[idx] parent wholesomepotato 2 years ago
a = v ^ 0x30303030lu // normalize to digits 0xXX0a0b0c
b = (a << 12) | a // combine into XXXXXbacb0c
idx = (b >> 12) & 0xfff // get bac
res = lookup[idx]