Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: "A diagram of C23 basic types" Date: Fri, 27 Jun 2025 17:56:33 -0700 Organization: None to speak of Lines: 38 Message-ID: <87tt40znsu.fsf@nosuchdomain.example.com> References: <87y0wjaysg.fsf@gmail.com> <20250403150210.000020f8@yahoo.com> <86selt8lxv.fsf@linuxsc.com> <20250428162738.00007c1d@yahoo.com> <103j290$3bv4a$1@dont-email.me> <8734bm1eqz.fsf@nosuchdomain.example.com> <20250626235916.00003314@yahoo.com> <87y0teyrg7.fsf@nosuchdomain.example.com> <103kvst$3tgp3$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Sat, 28 Jun 2025 02:56:35 +0200 (CEST) Injection-Info: dont-email.me; posting-host="4aad1424370974cd6bafff39b5dee9d5"; logging-data="498838"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RKV7VWG1RbM8NERJ5k7Eo" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:QYpMUQE+7GXBHGknKf91MSvQ/hQ= sha1:5++FwVzojfeTtm8i52JCxkr/sRM= Xref: csiph.com comp.lang.c:393931 Janis Papanagnou writes: > On 27.06.2025 02:10, Keith Thompson wrote: >> scott@slp53.sl.home (Scott Lurndal) writes: >> [...] >>> But not all decimal floating point implementations used "hex floating point". >>> >>> Burroughs medium systems had BCD floating point - one of the advantages >>> was that it could exactly represent any floating point number that >>> could be specified with a 100 digit mantissa and a 2 digit exponent. >> >> BCD uses 4 bits to represent values from 0 to 9. That's about 83% >> efficent relative to pure binary. (And it still can't represent 1/3.) > > That's a problem of where your numbers stem from. "1/3" is a formula! 1/3 is also a C expression with the value 0. But what I was referring to was the real number 1/3, the unique real number that yields one when multiplied by three. My point is that any choice of radix in a floating-point format means that there are going to be some useful real numbers you can't represent. That's as true of decimal as it is of binary. (Trinary can represent 1/3, but can't represent 1/2.) Decimal can represent any number that can be exactly represented in binary *if* you have enough digits (because 10 is multiple of 2), and many numbers like 0.1 that can't be represented exactly in binary, but at a cost -- that is worth paying in some contexts. (Scaled integers might sometimes be a good alternative). I doubt that I'm saying anything you don't already know. I just wanted to clarify what I meant. [...] -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */