Created
February 15, 2016 07:10
-
-
Save miloyip/55b3ff2d53a17ca5110e to your computer and use it in GitHub Desktop.
IsWhitespace_Arithmetic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline uint32_t IsWhitespace_Arithmetic(char c) { | |
uint32_t v = (static_cast<uint32_t>(c) * 0x01010101u) ^ 0x200A0D09u; | |
return (v - 0x01010101u) & ~v & 0x80808080u; // https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment