Quote:
Originally posted by joe_bruin
c++ does not define a byte at all.
a char must be of size 1. however many bits are in "1" is undefined, but a char must be able to store the "basic character set". this can be accomplished in 7 bits.
c99: 6.2.5
2. An object declared as type char is large enough to store any member of the basic execution character set. If a member of the required source character set enumerated in 5.2.1 is stored in a char object, its value is guaranteed to be positive. If any other character is stored in a char object, the resulting value is implementation-defined but shall be within the range of values that can be represented in that type.
as to the original question, see the bit-shift operators (<<, >>)
|
Thinking again:
C++ is not based on C99 but C90.
I am sure that a minimal of 8 bits are guaruanteed. The value -127 +127 are guaranteed for a byte.
The trick is that CHAR_BIT = 8.
- number of bits for the smallest object that is not a bit-field (byte)
Defined here:
5.2.4.2.1
Sizes of integer types