Article View: comp.lang.c
Article #973Re: .5 against 0.5f
From: Keith Thompson
Date: Wed, 28 Oct 2026 21:26
Date: Wed, 28 Oct 2026 21:26
27 lines
2376 bytes
2376 bytes
David Brown <david.brown@hesbynett.no> writes:
> On 28/10/2026 01:49, Lawrence D’Oliveiro wrote:
>> 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.
>
> Try thinking harder.
>
> I use the "f" suffix all the time in my code, because I do not want
> double precision. In many situations, single precision arithmetic is
> at least twice as fast as double precision - in some situations it can
> be two orders of magnitude faster.
If you define objects as type float rather than double, do you have
examples of code where using 0.1f rather than 0.1 makes a difference?
One simple example: These two declarations result in identical code
using gcc:
float f = 0.1f;
float f = 0.1;
--
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:
<11btp9d$2ojn1$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> <11bs8rb$26dq0$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: Wed, 28 Oct 2026 14:26:05 -0700 Organization: None to speak of Lines: 27 Message-ID: <11btp9d$2ojn1$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> <11bs8rb$26dq0$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 28 Oct 2026 21:26:06 +0000 (UTC) Injection-Info: kst.eternal-september.org; logging-data="2903777"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bFpmquUP3a9n8grzBhGbF"; posting-host="ac4e6fa4e505b2147f0d092402a060c4" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:vymz5rhzy6Cdt6wNZes6w/D+GDQ= sha256:Atj8r0DL+gfy54D4Mw5KmjNIKoMQNtgaItKQWoVUetI= sha1:xIWkoIrSA9ciTh21R9BQD6Kkpeg= sha256:v2sg/dyRF/XjxBBxgCU5TtBkosJhEtRvL6dvTm1Ih9Q=