Article View: comp.lang.c++
Article #758Re: does an expression in a logical statement need parenthesis for proper evaluation?
From: Scott Lurndal
Date: Fri, 06 Nov 2026 15:56
Date: Fri, 06 Nov 2026 15:56
23 lines
1911 bytes
1911 bytes
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.
Technical Details
Message-ID:
<7NmHS.316764$_pxc.137904@fx17.iad>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mailReferences:
<11cj4a0$23796$1@dont-email.me> <11cj7mg$23539$2@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!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail X-newsreader: xrn 9.03-beta-14-64bit Sender: scott@dragon.sl.home (Scott Lurndal) From: scott@slp53.sl.home (Scott Lurndal) Reply-To: slp53@pacbell.net Subject: Re: does an expression in a logical statement need parenthesis for proper evaluation? Newsgroups: comp.lang.c++,comp.lang.c References: <11cj4a0$23796$1@dont-email.me> <11cj7mg$23539$2@dont-email.me> Lines: 23 Message-ID: <7NmHS.316764$_pxc.137904@fx17.iad> X-Complaints-To: abuse@usenetserver.com NNTP-Posting-Date: Fri, 06 Nov 2026 15:56:51 UTC Organization: UsenetServer - www.usenetserver.com Date: Fri, 06 Nov 2026 15:56:51 GMT X-Received-Bytes: 1656