Re: how to print it out
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Tue, 21 Feb 2006 05:29:02 GMT
Jack Klein <jackklein@xxxxxxxxxxx> writes:
On Tue, 21 Feb 2006 05:00:19 +0200, "stathis gotsis"[...]
<stathisgotsis@xxxxxxxxxxx> wrote in comp.lang.c:
Is char restricted to 8 bits? If not, maybe this is more general:
No, char is not restricted to 8 bits, it can't be less buy may be
more. I routinely work on C implementations for DSPs where chars have
16 or 32 bits. The macro CHAR_BIT in <limits.h> gives the number of
bits.
#define nyb_u(a) (((a)>>(sizeof(a)*8-4))&0x0F)
Uh, no, while char is not limited to 8 bits, it is limited to being
exactly one byte. sizeof(char) is 1 by definition in C, always has
been, always will be. Even if char contains more than one octet,
which is the proper term for a collection of exactly 8 bits.
So your expression is exactly equivalent to Rod's.
Except that character constants are of type int, so nyb_u('x') will
use sizeof('x'), which is the same as sizeof(int). You probably
don't want to apply sizeof to the argument.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- References:
- how to print it out
- From: poison . summer
- Re: how to print it out
- From: Rod Pemberton
- Re: how to print it out
- From: stathis gotsis
- Re: how to print it out
- From: Jack Klein
- how to print it out
- Prev by Date: Re: String to Octal
- Next by Date: Re: Weird realloc() error
- Previous by thread: Re: how to print it out
- Next by thread: Re: how to print it out
- Index(es):
Relevant Pages
|