Re: Simple C question...entering binary





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



.



Relevant Pages

  • Re: Simple C question...entering binary
    ... binary digits into logical groups, for example with underscores as in ... the Ada form: ... Perhaps the C compilers that support the 0b... ... I like the spacer syntax. ...
    (comp.arch.embedded)
  • Re: Simple C question...entering binary
    ... the Ada form: ... grouped according to the logical fields of the encoding. ... Perhaps the C compilers that support the 0b... ... I like the spacer syntax. ...
    (comp.arch.embedded)
  • Re: How do I tell Word 2003 my mail-merge text is NOT UTF-8?
    ... supported by the tool in which the programs are developed (Borland Developer ... the data source come from a variety of places. ... of OpenDataSourcedoes not have an encoding parameter as Documents.Open ... If you are using Word 2000, that can't work because it doesn't support OLE ...
    (microsoft.public.word.mailmerge.fields)
  • Unicode text editor mined 2000 release 14
    ... Mined provides both extensive Unicode and CJK support offering many ... New command Alt-x toggles preceding character and its hexadecimal code. ... just determines and displays terminal encoding. ... supporting wide range of terminals ...
    (comp.editors)
  • Unicode text editor mined 2000 release 14
    ... Mined provides both extensive Unicode and CJK support offering many ... New command Alt-x toggles preceding character and its hexadecimal code. ... just determines and displays terminal encoding. ... supporting wide range of terminals ...
    (de.comp.editoren)