Skip to content

Instantly share code, notes, and snippets.

@stfwn
Created September 6, 2019 10:13
Show Gist options
  • Save stfwn/62e52cce89d6b226db92dc90abc52ee7 to your computer and use it in GitHub Desktop.
Save stfwn/62e52cce89d6b226db92dc90abc52ee7 to your computer and use it in GitHub Desktop.
int isAsciiDigit(int x) {
int overflower = (1 << 31) ^ (~0x39);
int overflowed = (x + overflower) >> 31;
if (overflowed) {
printf("Overflowed, so not an AsciiDigit.\n");
}
return !overflowed & !((x >> 4) ^ 3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment