--- In [email protected], Jim Smith <jmclauri...@...> wrote:
>
> Types bool, char, wchar_t, and the signed and unsigned
> integer types are collectively called integral types.
In C++ yes, however the C standard only uses the word
'integral' to refer to the integer component of a floating
point value.
Of course, there's little confusion between the terms
integral and integer types.
> On my system type char is 8 bits, short int is 16 bits,
> int is 32 bits, long long is 64 bits.
Note that long long is not a standard C++ type yet... AFAIK.
> I can define the types you mentioned like this:
>
> p, li { white-space: pre-wrap; }
Is it your email client inserting these? You might want to
check your settings. [Note that yahoo has a Test group.]
> typedef char int8;
Better is...
typedef signed char int8;
...since char may be either signed or unsigned. The name
int8 implies a signed type. The unsigned type is often
explicitly labelled uint8.
Using signed char also carries a modicum of type safety
since it's less likely to be associated with ordinary
characters.
> typedef short int int16;
> typedef int int32;
>
> p, li { white-space: pre-wrap; }
>
> cout << " char " << sizeof(int8)
<snip>
Note that sizeof yields the number of bytes, not the number
of bits. [And the size of a byte is always 1 byte!] To get
the bits in the representation, you need to multiply by
CHAR_BIT from <climits>. Which raises the issue of padding
bits, but I won't go into that... ;-)
--
Peter