🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++
Article #764

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

#764
From: Lynn McGuire
Date: Fri, 06 Nov 2026 21:19
31 lines
2665 bytes
On 11/6/2026 9: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.

Since 2022 on and off.  Customers have demands on my time.

You are confusing the upgrading of my Fortran code from Fortran II to 
Fortran 66 that did take roughly a decade.

Lynn
Technical Details
Message-ID: <11clg93$2tc16$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: <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: Lynn McGuire <lynnmcguire5@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 15:19:29 -0600
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <11clg93$2tc16$1@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:19:31 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3059750"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18znct+6Mk5RLerdU+QTrPkKzNZ8x6LzcM="; posting-host="9424d41671042b4b3ea15a90032ad150"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:lCq7wAM/rYTA9k7vck/Kc7+oO00= sha256:tf5rK4LLCxZpP6y4p+Ie74jldc3kEu2KVyzFKJ/SL7Y=
	sha1:8e96ydXRMXxqD1smc0wlXga33+c= sha256:6OMeCqGHOIYhZjoPcLr4WqssT9f6dYf/HyVh7qCyd74=
In-Reply-To: <7NmHS.316764$_pxc.137904@fx17.iad>
Content-Language: en-US