Name: Anonymous 2008-08-29 13:31
...access individual bits in a byte in C++?
int18 you would normally just use a long (are those extra bits really gonna hurt you?), but if you insist on having the smallest sufficient type you can use the preprocessor to pick the right one.#include <limits.h>
#include <stdio.h>
typedef
#if SCHAR_MAX >= 131071
signed char
#elif SHORT_MAX >= 131071
short
#elif INT_MAX >= 131071
int
#else
long // We know it's big enough
#endif
int18;
int main(void)
{
printf("%d\n", CHAR_BIT * sizeof(int18));
}