Hacker News new | ask | show | jobs
by hairtuq 2093 days 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;
    }
1 comments

The 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.