| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | malloc question |
NM>
> What's wrong with:
>
> int
> main(void)
> {
> printf("Unsigned Ints have %u bits.\n",
> sizeof(unsigned int) * CHAR_BIT);
>
> return 0;
> }
NM>
Strictly speaking, it's not portable. Although it is generally agreed
that in ISO Standard C there are no "hidden bits" in an unsigned char
(in order to satisfy some of the semantics of memcpy()), it is *not*
guaranteed that other integral types will not have hidden bits.
In other words, the number of available bits in any integral type may
be *less* than the number of `char's wide that the type is (i.e. sizeof)
multiplied by the number of bits in a `char'.
Of course, this doesn't apply to Intel platforms, and I don't believe
that it applies to PowerPC either. However, it is allowed by the ISO
Standard because it *may* apply to other platforms (imagine a platform
where all integers have a hardware parity bit, for example).
But as far as Intel OS/2 and PowerPC OS/2 are concerned anyway (let's
get back on topic here), `unsigned int' has 32 bits.
> JdeBP <
___
X MegaMail 2.10 #0:
--- Maximus/2 3.00
* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4)SEEN-BY: 270/101 620/243 711/401 409 410 413 430 808 809 934 955 712/407 515 SEEN-BY: 712/517 628 713/888 800/1 7877/2809 @PATH: 440/4 141/209 270/101 712/515 711/808 809 934 |
|
| 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™.