🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1106

Re: .5 against 0.5f

#1106
From: David Brown
Date: Thu, 29 Oct 2026 09:59
40 lines
3065 bytes
On 28/10/2026 23:12, Michael S wrote:
> On Wed, 28 Oct 2026 14:26:05 -0700
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> 
>> 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;
>>
> 
> David almost certainly was talking about use of 0.1f in arithmetic
> expressions rather than in simple initialization.
> 
Yes, that is the most relevant usage.

But I would not write "float f = 0.1;" either.  "float f = 0.1f;" is 
more explicit, and it would not risk accidentally triggering any static 
analysis (or human analysis) that checks for unintended use of doubles. 
(gcc's "-Wdouble-promotion" does not trigger on "float f = 0.1;", but 
other tools might.)
Technical Details
Message-ID: <11bv5dt$37mbb$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> <11br792$1u7e5$1@dont-email.me> <11brgqf$21170$2@dont-email.me> <11bs8rb$26dq0$1@dont-email.me> <11btp9d$2ojn1$4@kst.eternal-september.org> <20261029001256.00001179@yahoo.com>

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: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Thu, 29 Oct 2026 10:59:24 +0100
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <11bv5dt$37mbb$1@dont-email.me>
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>
 <11btp9d$2ojn1$4@kst.eternal-september.org>
 <20261029001256.00001179@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 29 Oct 2026 09:59:25 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3397995"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+CKcw8U4TZBXHB+CM+hnJf140c8B/XdcU="; posting-host="ee186c62f9168531a82b8aa89ffdfee0"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:e8zH1BkOAQJcYioJ0kRv49ggEwA= sha256:Y1H2OZC3i0x+rZFfuGefkF+5DE0UeEuntATZ2YmYo4Y=
	sha1:G+g2CVV07q6NuBERIstRCpZIcmc= sha256:7l23ZI6dEe3QPsgas100GZtEtjDbJz9dI7PFPczKJc8=
In-Reply-To: <20261029001256.00001179@yahoo.com>
Content-Language: en-GB, nb-NO