Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #66760

Re: Radix constant notation would eat binary for Elevensies.

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Radix constant notation would eat binary for Elevensies.
Date 2015-08-02 17:04 -0700
Organization None to speak of
Message-ID <lnbnepi6em.fsf@kst-u.example.com> (permalink)
References <3bc451b6-8f98-4e20-ae6f-d28340c41509@googlegroups.com>

Show all headers | View raw


luser droog <luser.droog@gmail.com> writes:
> I've been following the drifted topic of binary constants
> in the thread 'SQL filsortcc question'. But my idea is better.
>
> Existing syntax for hexadecimal constants:
>
>   0xabcdefg0
>   0XABCDEFG0

G??

> Suggested extension to binary constants:
>
>   0b101010101
>   0B101010101
>
> But what about?
>
>   2x101010101
>   2X101010101
>
> Thus, 0 becomes a shorthand for 16, and the same mechanism
> naturally extends up to 36 by including the remainder of 
> the Latin alphabet. The capitalization of 'x' retains the
> same significance in selecting the case of the representation
> whereas: `0B` ???

I like it, and if I were designing a new language from scratch I'd be
very tempted to use this notation.  8x123 reads better than 0123.  It
has the advantage of better uniformity (with "0x" as a special-case
alias for "16x") and generality (no arbitrary restriction to bases 2, 8,
10, and 16).

Given that the suggested 0b11001001 notation is already supported in C++
and as a gcc extension, I'd still argue in favor of standardizing that
for C.  The utility of bases other than 2, 8, 10, and 16 is not IMHO
that much of an advantage.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Radix constant notation would eat binary for Elevensies. luser droog <luser.droog@gmail.com> - 2015-08-02 10:28 -0700
  Re: Radix constant notation would eat binary for Elevensies. luser droog <luser.droog@gmail.com> - 2015-08-02 10:39 -0700
  Re: Radix constant notation would eat binary for Elevensies. Bartc <bc@freeuk.com> - 2015-08-02 18:56 +0100
  Re: Radix constant notation would eat binary for Elevensies. Robert Wessel <robertwessel2@yahoo.com> - 2015-08-02 14:14 -0500
    Re: Radix constant notation would eat binary for Elevensies. luser droog <luser.droog@gmail.com> - 2015-08-02 13:28 -0700
  Re: Radix constant notation would eat binary for Elevensies. Keith Thompson <kst-u@mib.org> - 2015-08-02 17:04 -0700

csiph-web