Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Radix constant notation would eat binary for Elevensies. Date: Sun, 02 Aug 2015 17:04:33 -0700 Organization: None to speak of Lines: 43 Message-ID: References: <3bc451b6-8f98-4e20-ae6f-d28340c41509@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="5374"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XnUd2DSBdleYWTzsk7Mh0" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:X/kPZ55TdIUx1FmIYt+rqMWTadU= sha1:jX+1Q+oGjNlhHPOWql3fYive/jo= Xref: csiph.com comp.lang.c:66760 luser droog 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 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"