🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #989

Re: .5 against 0.5f

#989
From: Janis Papanagnou
Date: Wed, 28 Oct 2026 23:27
51 lines
3460 bytes
On 2026-10-28 23:44, Steven G. Kargl wrote:
> On Wed, 28 Oct 2026 13:31:06 -0700, Keith Thompson wrote:
>> "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
>>> [...]
>>>
>>> float foo(float a) {
>>>    float x = 25 * a;
>>>    return (x);
>>> }
>>>
>>> A compiler ought to convert 25 in the above to
>>> 25.f as 25 is exactly representable (at least in
>>> IEEE-754 binary32 format) in float.
>>
>> I disagree.  Yes, the int constant 25 is implicitly converted to float
>> as part of the "usual arithmetic conversions".  But I find
>>      float x = 25.0 * a;
>> or even
>>      float x = 25.0f * a;
>> clearer than
>>      float x = 25 * a;
> 
> ROTL.  You find '25 * a' too difficult to realize
> that it is twenty-five times a.  The 2 or 3 extra
> digits (i.e., '.', '0', and 'f') are nothing but
> fluff.

I basically agree with Keith here.

It's not about "realizing" the _mathematical_ meaning of "25 * a",
or about having a clearer/terser (less "fluffy") expression.

I'm sure the compiler would be able to create the correct internal
representation based on the program context; in that respect the
"25" should suffice, and not even impose any additional conversion
operation. IMO. (There might be some hindrance based on C's design
that I'm not aware of, though.)

 From a programmers' perspective it always appeared useful to see
the type of the involved components in expressions. That's way I
write in every language "25.0" if I want to express a Real value.
(In some language it can even be functionally important, or even
be mandated.)

Where I disagree is that the 'f' would be meaningful as "concept"
(even if in "C" there's two "sorts" of floats, and two literals
for the same abstract numeric domain of real numbers). (But see
my disclaimer above about possible home-brewed hindrances in "C".)

Janis
Technical Details
Message-ID: <11bu0ds$139ta$13@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> <11brkco$21oj5$1@dont-email.me> <11bs4tj$26daj$1@dont-email.me> <11bs613$26knh$1@dont-email.me> <11bt7ff$2i0ag$1@dont-email.me> <11btm2a$2ojn1$2@kst.eternal-september.org> <11bttrp$2qvg6$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!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Thu, 29 Oct 2026 00:27:56 +0100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <11bu0ds$139ta$13@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> <11brkco$21oj5$1@dont-email.me>
 <11bs4tj$26daj$1@dont-email.me> <11bs613$26knh$1@dont-email.me>
 <11bt7ff$2i0ag$1@dont-email.me> <11btm2a$2ojn1$2@kst.eternal-september.org>
 <11bttrp$2qvg6$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 28 Oct 2026 23:27:56 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1157034"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+A+rf17o7JZYUk6yBf88yg"; posting-host="880663668c89bd06f8f144317597f206"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:27Ji7urbcqonpW9mr1BOX5wW1MQ= sha256:G2I/BqApCvxdiTRkhuLUr5hYR8X0LJbp7XUXCaGrhYU=
	sha1:1dKrtS3KdlpuBZOwpYU/h4o18hA= sha256:EXLxTzvhgbcsZD6/+1V+xN1NCGDbRuJh5/FgtCIS4RE=
In-Reply-To: <11bttrp$2qvg6$1@dont-email.me>
Content-Language: en-US