Afficher un message
Vieux 18/10/2007, 16h06   #5
Erik Trulsson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Finding number of bits of integer

vipvipvipvip.ru@gmail.com wrote:
> It is CHAR_BIT and not CHAR_BITS, ignoring that, if sizeof(anything)
> == 2
> we know that it's twice the size of a `char'.


Yes, but we do not know that it contains twice as many 'usable' bits.

E.g. one could have

CHAR_BIT == 9
sizeof(int) == 2
INT_MIN == -32767
INT_MAX == 32767

and it would be perfactly fine as far as the C standard is concerned.
In this case an int would occupy 18 bits, but 2 of those bits would
be padding and such an int would not be able to hold than a 16-bit wide
int without padding would.




--
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se
  Réponse avec citation
 
Page generated in 0,07041 seconds with 9 queries