Path: csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Spurious diagnostic messages Date: Sun, 02 Aug 2015 15:31:21 -0700 Organization: None to speak of Lines: 40 Message-ID: References: <874mn5ty3y.fsf@kst-u.example.com> <87egm8qis7.fsf@kst-u.example.com> <51drra5l8kp2okl6m99fpfuppmo5n1g16d@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="23443"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185HiaKlenI3xiY0IDzqqo4" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:zh5xSsXjZZCDyoGDoZfMFrHtjt4= sha1:BltNusi7CPtFtm09dJZqhj3MIn8= Xref: csiph.com comp.lang.c:66752 Bartc writes: [...] > What about binary FP constants? > > (I tried this in my non-C language: > > print 0B11.101 > > output when told to translate to C: > > printf("%f",3.625); > > Which I was surprised at as I can't remember implementing it. However it > needs some attention as 0B11.101e100 doesn't work. It's also not that > clear whether the exponent should be a power of 10, or of 2. > > Binary FP output is not available as that uses C's sprintf, which > doesn't support it.) C already has hexadecimal floating-point constants, using 'P' rather than 'E' to mark the exponent (since 'E' is a valid hexadecimal digit). The exponent represents a power of 2. *If* binary FP constants were to be added to C, they should be just like hexadecimal FP constants but with a "0b" prefix rather than "0x". Thus 0b1.1p3 == 12.0. I don't suggest that binary FP constants (or I/O) would be worthwhile. Non-decimal floating-point is not as human-readable as non-decimal integers, and hexadecimal already serves the purpose of capturing the exact value (for systems where FLT_RADIX is a power of 2). (Incidentally, Ada supports numeric constants and I/O using all bases from 2 to 16.) -- 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"