<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
I like this definition of Byte from the Wikipedia:<br><br>"A contiguous sequence of bits within a binary computer that comprises the <i>smallest addressable sub-field</i> of the computer's natural <a href="http://en.wikipedia.org/wiki/Word_%28computing%29" title="Word (computing)">word</a>-size."<br><br><br>Makslane<br><br><br>> Date: Fri, 2 Jan 2009 17:28:43 +0200<br>> From: edwintorok@gmail.com<br>> To: cfe-dev@cs.uiuc.edu<br>> Subject: [cfe-dev] On sizeof char, bytes, and bits in the C99 standard<br>> <br>> Hi,<br>> <br>> I always considered sizeof(char) = one byte = 8 bits.<br>> However reading the C99 standard (N1256.pdf), and especially the C99<br>> rationale (C99RationalV5.10.pdf) I see that the intent is to allow<br>> for platforms where one byte != 8 bits.<br>> <br>> For example:<br>> "(Thus, for instance, on a machine with 36-bit words, a byte can be<br>> defined to consist or 36 bits, these numbers being all the exact<br>> divisors of 36 which are not less than 8.)"<br>> <br>> So I read several sections of the C99 standard and the rationale, and if<br>> you combine the standard with the rationale you get the only way to<br>> satisfy all the rules,<br>> is to have one byte = 8 bits. So why all this careful, generic<br>> formulations to avoid defining one byte == 8 bits, when in fact you<br>> can't have an implementation<br>> where one byte != 8 bits that conforms to the standard/rationale.<br>> <br>> Section 3.7.1 says "character single-byte character 〈C〉 bit<br>> representation that fits in a byte", which is further strengthened by<br>> C99RationaleV5.10: " A char whether signed or unsigned, occupies exactly<br>> one byte.".<br>> Thus no doubt one character = one byte.<br>> <br>> Section 3.6 defines byte: "NOTE 2 A byte is composed of a contiguous<br>> sequence of bits, the number of which is implementation-defined. The<br>> least significant bit is called the low-order bit; the most significant<br>> bit is called the high-order bit."<br>> <br>> Section 7.18.1.1 defines int8_t: "Thus, int8_t denotes a signed integer<br>> type with a width of exactly 8 bits."<br>> <br>> This quote from C99Rationale V.5.10 " Thus, for instance, on a machine<br>> with 36-bit words, a byte can be defined to consist of 9, 12, 18, or 36<br>> bits, these numbers being all the exact divisors of 36 which are not<br>> less than 8.)" shows that the intent was to allow for a definition of<br>> byte that doesn't necessarily have 8 bits.<br>> <br>> However according this quote " These strictures codify the widespread<br>> presumption that any object can be treated as an array of characters,<br>> the size of which is given by the sizeof operator with that object’s<br>> type as its<br>> operand."  I should be able to treat any objects (thus including int8_t<br>> type objects) as array of characters.<br>> This implies that there exists an N such that: number_of_bits(char)*N =<br>> number_of_bits(int8_t). Given what we know about char and int8_t this means:<br>> there exists an N such that number_of_bits(byte)*N = 8, which implies<br>> number_of_bits(byte) <= 8.<br>> <br>> Now according to C99Rationale V5.10: " All objects in C must be<br>> representable as a contiguous sequence of bytes, each of which  is at<br>> least 8 bits wide.",<br>> number_of_bits(byte) >= 8.<br>> <br>> Thus number_of_bits(byte) = 8.<br>> <br>> Am I right, or am I wrong?<br>> <br>> Best regards,<br>> --Edwin<br>> _______________________________________________<br>> cfe-dev mailing list<br>> cfe-dev@cs.uiuc.edu<br>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br><br /><hr />Veja mapas e encontre as melhores rotas para fugir do trânsito com o Live Search Maps! <a href='http://www.livemaps.com.br/index.aspx?tr=true' target='_new'>Experimente já!</a></body>
</html>