🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1144

Re: .5 against 0.5f

#1144
From: Steven G. Kargl
Date: Fri, 30 Oct 2026 02:08
99 lines
5333 bytes
On Fri, 30 Oct 2026 01:27:03 -0000 (UTC), Dan Cross wrote:

> In article <86se1oku25.fsf@linuxsc.com>,
> Tim Rentsch  <tr.17687@z991.linuxsc.com> wrote:
>>"Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
>>
>>> On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:
>>>
>>>> "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
>>>>
>>>>> On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:
>>>>>
>>>>>> (Also, you misspelled "ROFL", and you don't need parentheses on the
>>>>>> return statement, particularly if you dislike fluff.)
>>>>>
>>>>> Yeah, I was laugh too hard while typing ;-)
>>>>>
>>>>> Parentheses is a habit from BSD kernel source file style guide.
>>>>
>>>> Now is a good time to start unlearning that habit.
>>>
>>> Why?  What harm do the parentheses cause?
>>
>>Wrong question.  The important question is what benefit do they
>>give?  Granted, there may be circumstances where there is some
>>benefit.  But what benefit justifies using parentheses in *all*
>>circumstances?
> 
> Consistency with existing code and conformance with an
> externally mandated style guide, obviously.
> 
>>> Unlearning is not likely to happen.  I've been a long-time
>>> contributor to FreeBSD, and have no plans to stop.  Feel
>>> free to check the git history on FreeBSD libm sources.
>>> My finger prints are all over the code.  So, yeah, I know
>>> a enough about floating point arithmetic and C standard
>>> requirements to be dangerous.
>>>
>>>>> % man 9 style
>>>>> ...
>>>>>
>>>>>      Values in return statements should be enclosed in parentheses.
>>>>>
>>>>>
>>>>> I also have debugging macros RETURNI() that require parens.
>>>>
>>>> That strengthens the motivation not to use parentheses with
>>>> return statements, to emphasize that they are different from
>>>> the macros.
>>>
>>> Do you ignore the style requirements of all the projects
>>> that you may have worked on, and simply use whatever
>>> your personal preferences are?
>>
>>Please note what I said.  I did not say never to use parentheses.
>>What I did say is that now is a good time to start unlearning the
>>habit of (always) using parentheses.  If you're writing code
>>destined for FreeBSD, by all means put in the extra parentheses.
>>On the other hand, if you're writing code to put in a posting for
>>comp.lang.c, it's more common not to use extra parentheses.  When
>>in Rome, do as the Romans do.  If you have a compelling reason to
>>use such redundant parentheses here in the newsgroup, please tell
>>us what it is.  Otherwise, is it you who is ignoring the style
>>norms of the group who will be reading your code?
> 
> This newsgroup has no "norms" for code style.  Period.
> 
> You are stating your preference as if it is some agreed upon, de
> facto standard.  It is not, nor is it a requirement for posting
> here.  No one posting here is obligated to omit the parentheses
> to satisfy the whims of you, me, or anyone else.  Hell, they can
> unironically use the GNU style if they really want.
> 
> OP: you want to parenthesize the expression in a `return`
> statement because that's what you're used to from FreeBSD?  Go
> for it.  Some folks may find it unnecessary; that's fine.  But
> don't listen to someone trying to tell you that you're violating
> some set of invisible mores by doing so; that nonsense.

I have been lurking in c.l.c for over 2 decades.  I know that
there is no coding style guide, here.  I have contributed code
to both FreeBSD and GCC, again, for over 2 decades.  I'm
well-aware of the requirements in both FreeBSD's style(9) and
the GNU coding standard.  Neither use my preferred 3-space
indentation at all indentation levels.  Oh well.

C23, Annex A shows the syntax rule: 'return expression_{opt}'
with _{opt} denoting a subscript.  Unsurprisingly, 6.5.2 shows

primary-expression:
   ...
   ( expression )
   ...

so, the code I posted with 'return (0)' is standard conforming.

-- 
steve
Technical Details
Message-ID: <11c0u6a$3sm15$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> <868q3hmie0.fsf@linuxsc.com> <11bu8oi$2up7m$1@dont-email.me> <86se1oku25.fsf@linuxsc.com> <11c0rp7$lif$1@reader2.panix.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: "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu>
Newsgroups: comp.lang.c
Subject: Re: .5 against 0.5f
Date: Fri, 30 Oct 2026 02:08:10 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 99
Message-ID: <11c0u6a$3sm15$1@dont-email.me>
References: <11bpvs7$1e6kc$2@dont-email.me> <868q3hmie0.fsf@linuxsc.com>
	<11bu8oi$2up7m$1@dont-email.me> <86se1oku25.fsf@linuxsc.com>
	<11c0rp7$lif$1@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 30 Oct 2026 02:08:11 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="4085797"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19Ol3eFc2QHW75n+6cZDSuv"; posting-host="68fa1296f002ef090be9d85a902f963b"
User-Agent: Pan/0.164 (Kupiansk)
Cancel-Lock: sha1:0G2Km4BLCRGQoVEUrQGMQ3Exug4= sha256:Y9EsQ9uWKPs5kYx7vje3YlhwORsG77WdR9/m+7cwwNg=
	sha1:oi9MHXosOvBCO9Oqam0Q+WREnzU= sha256:eRepS0nVPXYk3A+yKtbvs2VS6mmuHR1xjOlmTnlw5C4=