TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Bob Stout
from: Jerry Coffin
date: 2003-11-16 18:02:38
subject: Re: [C] word sizes

From: Jerry Coffin 

At 03:25 PM 11/16/2003, you wrote:

[ ... ]

>To the question at hand... Referring to ISO/IEC 9899:1999, "5.2.4.2.1
>Sizes of integer types ", the only hard-wired type is char
>(signed or unsigned), for which CHAR_BIT is defined as 8.

I suspect you started out saying something accurate, and then tried to edit
it down to size, and ended up with something that wasn't quite accurate
anymore.

It is true that sizeof(char) is hardwired at 1.  CHAR_BIT, however, is a
minimum of 8, but can be larger -- in the last sentence of paragraph 1 of
4.2.4.2.1, it talks about CHAR_BIT and the other values in limits.h,
saying:  "Their implementation-defined values shall be equal or
greater in magnitude (absolute value) to those shown, with the same
sign."  IOW, if an implementation chose to use CHAR_BIT of 16 or 32 or
even 64, there would be nothing wrong with that.

There is one proviso to that: though never says so explicitly, for I/O to
work correctly (specifically for EOF to be unique from any input that could
have been read from the file) the range of int has to be greater than (not
equal to) the range for char.  IOW, if there are 64 bits in the value
representation of a char, then there had better be at least 65 bits in an
int, or the I/O model no longer works.


         Later,
         Jerry.

--- BBBS/LiI v4.01 Flag-5
* Origin: Prism bbs (1:261/38)
SEEN-BY: 633/267 270
@PATH: 261/38 123/500 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.