Octets calculation?

Erik Max Francis max at alcyone.com
Fri Jun 13 18:19:22 EDT 2003


Bengt Richter wrote:

> 1.6  The C++ memory model                               [intro.memory]
>
>1 The fundamental storage unit in the C++ memory model is the  byte.  
> A
>  byte  is at least large enough to contain any member of the basic
> exe-
>  cution character set and is composed of a contiguous sequence of
> bits,
>  the  number of which is implementation-defined.  The least
> significant
>  bit is called the low-order bit; the most significant  bit  is 
> called
>  the high-order bit.  The memory available to a C++ program consists
> of
>  one or more sequences of contiguous bytes.  Every byte  has  a 
> unique
>  address.
>
> which seems to imply that char and byte COULD have different numbers
> of bits.

This means it clear that a char can fit in a byte; it doesn't establish
that they're different entities.  Later comments in the Standards
indicate that char and byte are synonymous, although the Standards never
come right out and say it (which is a weird little quirk).

C99 has 3.6/1 (which is very similar to what you quote above; C++97's
version is a paraphrase of C99's 3.6/1-3), and has 3.7.1/1 which defines
a character as a "single-byte character; <C> bit representation that
fits in a byte."

5.2.1/3 reads, "The representation of each number of the source and
execution basic character sets shall fit in a byte,"  5.2.4.2.1/1
establishes that a byte must be at least 8 bits (but it could be more).

There are also other semantic hints, such as CHAR_BITS being the macro
definition of the number of bits in a byte (which is the same as a char,
hence the name).

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Procrastination is the thief of time.
\__/  Edward Young




More information about the Python-list mailing list