Re: [OFFTOPIC] Binary declaration

Mike A. Harris (mharris@ican.net)
Mon, 7 Dec 1998 04:30:37 -0500 (EST)


On Mon, 30 Nov 1998, Linux Lists wrote:

>Hi there,
>
>Dumb question (or for the ones who believe there is no such a thing,
>question from a dumb):
>
>Hex: 0x<NUMBER>
>Octal: 0<NUMBER>
>Binary: ????
>
>Thanks in advance and sorry for the offtopic.

In ANSI C, there is no binary representation available. Watcom C
I believe has an extention to allow you to use something like:

0b010101110

But ANSI does not allow this. There is a way of implementing it
in a portable way by creating a header file containing #define's
of all binary values like this:

#define b00000000 0x00
#define b00000001 0x01
#define b00000010 0x02
#define b00000011 0x03
...
#define b11111111 0xFF

That only accounts for 8 bit binary numbers however. You're
better off sticking to hex notation wherever possible, and
perhaps putting binary numbers in comments behind the hex
notation.

--
Mike A. Harris  -  Computer Consultant  -  Linux advocate

Linux software galore: http://freshmeat.net

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/