Article View: comp.lang.c
Article #908Re: .5 against 0.5f
From: Keith Thompson
Date: Wed, 28 Oct 2026 02:02
Date: Wed, 28 Oct 2026 02:02
42 lines
3091 bytes
3091 bytes
James Kuyper <jameskuyper@alumni.caltech.edu> writes:
> On 2026-10-27 18:53, Keith Thompson wrote:
>> James Kuyper <jameskuyper@alumni.caltech.edu> writes:
>> [...]
>>> The C constant "0.1" implicitly has a double value. It has "either the
>>> nearest representable value" to exactly 0.1, "or the larger or smaller
>>> representable value immediately adjacent to the nearest representable
>>> value, chosen in an implementation-defined
>>> manner." (6.5.4.3p4). Since it's double precision constant,
>>> "representable" means "representable as a double precision number".
>>
>> I think you gave the wrong subsection number, ...
> Yes, that should have been 6.4.5.3p4.
>
>> ... and you didn't specify
>> which version of the standard you're quoting from.
>
> The latest working draft I have access to, n3685.pdf, C202y. It refers
> to C23, and to dates as late as August 2025, using the past tense.
The draft closest to the C23 standard is N3220.
The latest C2y draft is N3998, just released a few days ago.
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3998.pdf
[...]
>> Using 0.1 in a context where it will be converted to float is likely
>> to be harmless. Converting 0.1 to float is likely to yield the same
>> value as 0.1f. That's probably not guaranteed, but if there is a
>> difference it's probably insignificant.
>
> Using 0.1f because you don't realize that you actually need double
> precision could be problematic. This thread was started by fir - I
> wouldn't rule out such a possibility.
Sure -- but I did specify "where it will be converted to float".
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Technical Details
Message-ID:
<11brl35$1uh9q$5@kst.eternal-september.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mailReferences:
<11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <11br5td$1to7l$1@dont-email.me> <11bra0u$1uh9q$2@kst.eternal-september.org> <11brkmg$22567$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!kst.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: .5 against 0.5f Date: Tue, 27 Oct 2026 19:02:12 -0700 Organization: None to speak of Lines: 42 Message-ID: <11brl35$1uh9q$5@kst.eternal-september.org> References: <11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <11br5td$1to7l$1@dont-email.me> <11bra0u$1uh9q$2@kst.eternal-september.org> <11brkmg$22567$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 28 Oct 2026 02:02:13 +0000 (UTC) Injection-Info: kst.eternal-september.org; logging-data="2049338"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ksEDa9QdroQvPgEnMG68U"; posting-host="ac4e6fa4e505b2147f0d092402a060c4" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:eBeqSdXSbiH+iR+uydQ8cAf6rrE= sha256:wwgxU7FdpF+t3/mNZB3PXaJ89Zab5hjxbQmdQDl50Eo= sha1:YVG3a7On2g9WGw2MhNIhtBtcR8A= sha256:HYuXBhK0+INHj28MQUuraDTtxsAl/tgzF4lJKw25SEM=