View Single Post
Old 10-16-2004, 01:21 PM   #8 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
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
__________________

Last edited by Valmont; 10-16-2004 at 01:55 PM.
Valmont is offline   Reply With Quote