Article View: comp.lang.c
Article #903Re: .5 against 0.5f
From: Keith Thompson
Date: Wed, 28 Oct 2026 01:23
Date: Wed, 28 Oct 2026 01:23
28 lines
2292 bytes
2292 bytes
Lawrence D’Oliveiro <ldo@nz.invalid> writes:
> On Tue, 27 Oct 2026 18:06:25 -0400, James Kuyper wrote:
>> However, if you need double precision, you shouldn't be using the
>> "f" suffix.
>
> Is there any situation where you *should* use the “f” suffix?
>
> I am thinking: no.
If you're working with values of type float, the "f" suffix is more
explicit.
Logically, something like
float f = 0.1;
implies a conversion from double to float, which could be non-trivial.
In practice, the conversion is likely to be done at compile time.
The result is *probably* the same as `float f = 0.1f;`, but I don't
think that's guaranteed.
I can't think of a case were writing 0.1f rather than 0.1 would
cause any real (ahem) problems, but there are plenty of cases where
someone might consider it stylistically better.
--
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:
<11brir0$1uh9q$4@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> <11br792$1u7e5$1@dont-email.me> <11brgqf$21170$2@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 18:23:43 -0700 Organization: None to speak of Lines: 28 Message-ID: <11brir0$1uh9q$4@kst.eternal-september.org> References: <11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <11br5td$1to7l$1@dont-email.me> <11br792$1u7e5$1@dont-email.me> <11brgqf$21170$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 28 Oct 2026 01:23:44 +0000 (UTC) Injection-Info: kst.eternal-september.org; logging-data="2049338"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JjM24lvMwMAo/ZB6n+KpQ"; posting-host="ac4e6fa4e505b2147f0d092402a060c4" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:AoiP7isa9a/tZ23fUHMHBnqghvk= sha256:XU4+edKQkO3W9BCjy5fSagDVSjmBkF/9ex2J/Q515xg= sha1:q34VMEXfCQOoDBHrxQTX7xyaYA4= sha256:i+njM2TiUK7mtm0dcf/hlTusQkPiXRCAGnZPYsjOYuc=