Path: ...!feed.opticnetworks.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown Newsgroups: comp.lang.c Subject: Re: Hex string literals (was Re: C23 thoughts and opinions) Date: Tue, 18 Jun 2024 17:20:12 +0200 Organization: A noiseless patient Spider Lines: 41 Message-ID: References: <00297443-2fee-48d4-81a0-9ff6ae6481e4@gmail.com> <87msoh5uh6.fsf@nosuchdomain.example.com> <87y18047jk.fsf@nosuchdomain.example.com> <87msoe1xxo.fsf@nosuchdomain.example.com> <87ikz11osy.fsf@nosuchdomain.example.com> <87plt8yxgn.fsf@nosuchdomain.example.com> <87cyp6zsen.fsf@nosuchdomain.example.com> <874jahznzt.fsf@nosuchdomain.example.com> <87v82b43h6.fsf@nosuchdomain.example.com> <87iky830v7.fsf_-_@nosuchdomain.example.com> <86v826kdxn.fsf@linuxsc.com> <20240618123940.00007f1a@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 18 Jun 2024 17:20:12 +0200 (CEST) Injection-Info: dont-email.me; posting-host="000ac22a82b477e7b73d30c4bbbc814d"; logging-data="1477655"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yxDZR+bHKU4c6Tyl26oj6Ba1gLw3eHOo=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:RUqYl9q7McVycee85e5hHR9xGYc= Content-Language: en-GB In-Reply-To: <20240618123940.00007f1a@yahoo.com> Bytes: 3406 On 18/06/2024 11:39, Michael S wrote: > On Mon, 17 Jun 2024 22:39:00 -0700 > Tim Rentsch wrote: > >> bart writes: >> >>> AFAIK nobody uses octal anymore. >> >> There are circumstances where being able to write constants >> in octal is useful. It also would be nice to be able to >> write constants in base 4 and base 32 (because 5 is half >> of 10). I don't have occasion to prefer octal very often >> but I'm glad it's there for those times when I do. > > Ada/VHDL permits any base from 2 to 16. They didn't go as far up as > 32. > I would imagine that reading base 32 number would take time to become > accustomed. I can't imagine any possible use for such bases. Base 16 is very common, and base 2 is useful in some circumstances. Base 8 has, to my knowledge, a single non-archaic use-case and that is for chmod modes in *nix programming. I think support for other bases exists in some languages as a side-effect of wanting an explicit numbered base notation for bases 2, 16 and possibly 8, rather than using 0b, 0x and 0o (or 0q, or just 0 as an April fool's joke). If I were the BDFL of C, I'd remove octal constants and add a macro "_Octal" with definition: #define _Octal(n) (((n) % 10) + ((n) / 10 % 10) * 8 \ + ((n) / 100 % 10) * 64 + ((n) / 1000 % 10) * 512) If anyone can present a good use for base 4 or base 32, I might change my mind :-)