Skip to content

Instantly share code, notes, and snippets.

@benstiglitz
Created February 27, 2012 21:59
Show Gist options
  • Save benstiglitz/1927376 to your computer and use it in GitHub Desktop.
Save benstiglitz/1927376 to your computer and use it in GitHub Desktop.
silly
#define is_signed(T) ({ intmax_t __s = -1; T __t = (T)__s; __t < 0; })
#define maxofint(T) (is_signed(T) == 0 ? \
((uintmax_t)1 << (sizeof(T) * 8)) - 1 : \
((uintmax_t)1 << (sizeof(T) * 8 - 1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment