Re: Simple C question...entering binary
- From: Walter Banks <walter@xxxxxxxxxxxxx>
- Date: Wed, 16 Jul 2008 10:02:46 -0400
David Brown wrote:
Reading binary numbers is easier when the language lets you separate the
binary digits into logical groups, for example with underscores as in
the Ada form:
2#10_10110_001000_11111_1_0000000010000#
which is the 32-bit encoding of the SPARC instruction "addx r31,16,r22",
grouped according to the logical fields of the encoding. The "_" has no
numerical meaning, so the above is the same as:
2#10101100010001111110000000010000#
Perhaps the C compilers that support the 0b... notation should allow
some form of grouping like this.
The Ada-style "_" spacer in numbers (for hex and decimal as well as bin)
would be a huge improvement to readability for longer strings. It
should also appeal to the "hosted" folk as well as the "non-hosted"
folk, so perhaps Walter might have some luck suggesting it to the powers
that be in the C world.
I like the spacer syntax. There is at least one C compiler that supports
spacers (not ours) I don't think that spacer syntax is likely to be introduced
into C anytime soon. C has never had it and there are some things that
need to be resolved long before this becomes a pressing issue.
In our case we added 0B... , 0b.... with the same syntax as hex support.
I recognize the argument for hex support only and legacy support for
octal notation. My customers are almost all non-hosted embedded
systems folks and we have supported their needs with the extension.
Walter Banks
Byte Craft Limited
.
- Follow-Ups:
- Re: Simple C question...entering binary
- From: Everett M. Greene
- Re: Simple C question...entering binary
- References:
- Re: Simple C question...entering binary
- From: CodeDog
- Re: Simple C question...entering binary
- From: Walter Banks
- Re: Simple C question...entering binary
- From: David Brown
- Re: Simple C question...entering binary
- From: Walter Banks
- Re: Simple C question...entering binary
- From: Robert Adsett
- Re: Simple C question...entering binary
- From: Niklas Holsti
- Re: Simple C question...entering binary
- From: David Brown
- Re: Simple C question...entering binary
- Prev by Date: 2 GB Pen Drive For Rs.399
- Next by Date: Re: Dallas DS18B20 CRC
- Previous by thread: Re: Simple C question...entering binary
- Next by thread: Re: Simple C question...entering binary
- Index(es):
Relevant Pages
|