3 ms·
Since the shift count is implicitly modulo 32, you don't even need the subtraction: bool isvowel(char c) { return (1u << (c&31)) & 0x208222; }
by hairtuq 6y ago
Since the shift count is implicitly modulo 32, you don't even need the subtraction:
bool isvowel(char c) {
return (1u << (c&31)) & 0x208222;
}
- ncmncm 6y agoThe result is unspecified, if you don't mask off the high bits. Some chips will do it implicitly, and give you the right answer anyway, unportably. This is why testing is not a substitute for correctness. Sometimes you get the right answer by accident. But it's good enough for code golf.