🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #952

Re: .5 against 0.5f

#952
From: Janis Papanagnou
Date: Wed, 28 Oct 2026 15:38
40 lines
2851 bytes
On 2026-10-28 02:23, Keith Thompson wrote:
> 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.

I think "logically" is a misleading word here.

The thought of something "implicit" going on here is a thought that
might stem from (knowing) the inherent mechanisms and quirks of the
C-language not necessarily what one would logically expect.

My expectation (for sensibly defined programming languages) would be
that literals for two different "real numbers" types are generic WRT
those types; they should be usable [in "C"] without loss (or kludges)
with 'float' and 'double'.

> 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.

Janis
Technical Details
Message-ID: <11bt4ua$139ta$8@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> <11brir0$1uh9q$4@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: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Wed, 28 Oct 2026 16:38:50 +0100
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <11bt4ua$139ta$8@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> <11brir0$1uh9q$4@kst.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 28 Oct 2026 15:38:50 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1157034"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18XsWwxpzb3I/VuRI/hsyDX"; posting-host="880663668c89bd06f8f144317597f206"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qgeDkZpUg6tyrzcivL5D80OEwX0= sha256:8KQILwchGz25rYFuqyrdXXxIBP5x0XjGekArgUtnwYo=
	sha1:vfQgoycvSZBUGObnSQg3G1nRORk= sha256:UsZ9Ww0FIcWqm1eiXw+DDxBx/cWky+kqdRomNtecN5A=
Content-Language: en-US
In-Reply-To: <11brir0$1uh9q$4@kst.eternal-september.org>