On Sat, 29 Aug 1998 15:58:08 +0300 (IDT) Moshe Zadka wrote:
>
> On Sat, 29 Aug 1998, Glynn Clements wrote:
>
> >
> > Moshe Zadka wrote:
> >
> > > > How do you use binary numbers in C? i'm sure i once knew...
> > > >
> > > > i know you prefix 0x to numbers for Hex, 0 for octal, what's binary...
> > >
> > > There is none. One of the major problems in C...
> >
> > Huh? In all of the time that I've been using C, I have never felt any
> > need to specify numbers in binary.
> >
> OK, I want the first and fourth bit of a byte (cause the flags there
> matter to me, say) x&0x9 can be used, but x&0b1001 seems a bit clearer.
> No?
>From the K&R C book I understand that the language syntax was intentionally kept
small to avoid "scope creep" that would lead to LANGUAGE bloat (e.g. P/L 1).
Language design like the rest of life is filled with trade-offs.
Your prefered syntax is clearer and consistent with close corresondence or at
least access to the underlying machine architecture, another of C's design
goals. I have always found bit twiddling cumbersum at best. We can only assume
that hex and octal representation provided the access and/or that literal bit
strings were "deprecated" and "counter-revolutionary" in the late sixties and
early seventies.
david
--
David Ross
[EMAIL PROTECTED]
Toad Technologies
"I'll be good! I will, I will !"