🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #907

Re: .5 against 0.5f

#907
From: James Kuyper
Date: Wed, 28 Oct 2026 01:55
32 lines
2964 bytes
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.

...>> You should use 0.1 when the value will be stored in a double or would
>> otherwise immediately get converted to double when used (which is often
>> the case). You should use 0.1f to initialize a float variable or to pass
>> an argument to a function whose prototype specifies that the
>> corresponding parameter has the type float.
> 
> 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.
Technical Details
Message-ID: <11brkmg$22567$1@dont-email.me>
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!.POSTED!not-for-mail
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>

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!.POSTED!not-for-mail
From: James Kuyper <jameskuyper@alumni.caltech.edu>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Tue, 27 Oct 2026 21:55:28 -0400
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <11brkmg$22567$1@dont-email.me>
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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 28 Oct 2026 01:55:29 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2168007"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18AewWD2wTfaViXiolODIbr0tHftOpDKEM="; posting-host="be7d11f9ed1c07f50d9d5deefef02134"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:+qDOh/B6KK3XbnicljmSxJV+uhQ= sha256:sOra7vFzwT+SNgE5XMVqCZGKFzjCxnxAth54nGfHJUk=
	sha1:uHqcufR/hFWvCp9uoYR9hpssaRg= sha256:Y5GuZuTg0KPBqE+yIkErLzEZSvdZg1lPWUhOkXVCiMI=
In-Reply-To: <11bra0u$1uh9q$2@kst.eternal-september.org>
Content-Language: en-US