🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1217

Re: does an expression in a logical statement need parenthesis for proper evaluation?

#1217
From: Chris M. Thomasson
Date: Fri, 06 Nov 2026 21:16
26 lines
2453 bytes
On 11/6/2026 7:56 AM, Scott Lurndal wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>> On 2026-11-06 00:42, Lynn McGuire wrote:
>>> Hi,
>>>
>>> Does an expression in a logical statement need parenthesis for proper
>>> evaluation in C and/or C++?
>>
>> No, below (assuming i1 and j1 are arithmetic types (and not used
>> as "camouflaged" booleans) there's no parenthesis necessary.
>>
>> The necessity of parentheses depends on the operators used. In
>> "C" the multiplication has higher precedence than the comparison.
>>
>> I suggest to get an Operator Precedence Table from the Net and
>> inspect it until you got familiar with the operator precedences.
>> Most precedences are anyway sensibly defined as you'd expect it.
>> But be careful when using bit-expressions with '&', '|', and '^'
>> especially if used together with the comparison operators.
> 
> Lynn has been working on his "fortran" -> "C++" conversion
> for over a decade now.   That he isn't familar with the
> C operator precedence table is rather frightening.
> 

Well, yeah. Shit.
Technical Details
Message-ID: <11clg3o$2t49r$4@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: <11cj4a0$23796$1@dont-email.me> <11cj7mg$23539$2@dont-email.me> <7NmHS.316764$_pxc.137904@fx17.iad>

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: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: does an expression in a logical statement need parenthesis for
 proper evaluation?
Date: Fri, 6 Nov 2026 13:16:40 -0800
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <11clg3o$2t49r$4@dont-email.me>
References: <11cj4a0$23796$1@dont-email.me> <11cj7mg$23539$2@dont-email.me>
 <7NmHS.316764$_pxc.137904@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 06 Nov 2026 21:16:41 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3051835"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19C0nhQOAY5QOkgSo7Bz+SoATDLy6ZE2f8="; posting-host="05131b9d92d665448b45480425c57f0b"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ZGFWxhvvOKrFDppJmSbEIxEazwE= sha256:6uMVencDAjPlkd+ndADDLJA9guEo8UL6nNBkGMUlmAE=
	sha1:48MlBwc6hmB8izqk+Li4AWI/I+U= sha256:U8m9wbfq4XaUBo2Ifm7mf4T45q5S68jw8lNEDkbK0yQ=
In-Reply-To: <7NmHS.316764$_pxc.137904@fx17.iad>
Content-Language: en-US