🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#839
From: Tristan Wibberley
Date: Thu, 12 Nov 2026 22:27
42 lines
3029 bytes
On 12/11/2026 19:44, Tristan Wibberley wrote:
> On 06/11/2026 01:12, Lawrence D’Oliveiro wrote:
>> On Thu, 5 Nov 2026 19:52:31 -0500, James Kuyper wrote:
>>
>>> For historical reasons, bitwise or (|) and bitwise and (&) are
>>> exceptions. Unfortunately, correcting that mistake would break
>>> backwards compatibility ...
>>
>> The only real issue is that bitwise ops have lower priority than
>> comparisons, when they should be higher. If they were higher, then an
>> expression like
>>
>>     (bitval & mask) == desired_value
> 
> 
> 
>> wouldn’t need parentheses.
>>
>> Realistically, can anyone offer *any* real-world C code that
>> uses an expression that would be parenthesized like
>>
>>     a & (b == c)
> 
> bitwise ops are well used to do logic on 'booleans'

oh yeah, for C this is all "int" so I think I would only want to do it
with 2s-complement architectures. I think C++ is fine because they're
"bool" instead.


-- 
Tristan Wibberley

The message body is Copyright (C) 2026 Tristan Wibberley except
citations and quotations noted. All Rights Reserved except that you may,
of course, cite it academically giving credit to me, distribute it
verbatim as part of a usenet system or its archives, and use it to
promote my greatness and general superiority without misrepresentation
of my opinions other than my opinion of my greatness and general
superiority which you _may_ misrepresent. You definitely MAY NOT train
any production AI system with it but you may train experimental AI that
will only be used for evaluation of the AI methods it implements.
Technical Details
Message-ID: <11d5eg2$bfhu$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11cj4a0$23796$1@dont-email.me> <11cj8ch$24f93$1@dont-email.me> <11cj9he$24mi0$1@dont-email.me> <11d54u2$863c$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk>
Newsgroups: comp.lang.c++,comp.lang.c
Subject: Re: does an expression in a logical statement need parenthesis for
 proper evaluation?
Date: Thu, 12 Nov 2026 22:27:14 +0000
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <11d5eg2$bfhu$1@dont-email.me>
References: <11cj4a0$23796$1@dont-email.me> <11cj8ch$24f93$1@dont-email.me>
 <11cj9he$24mi0$1@dont-email.me> <11d54u2$863c$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 12 Nov 2026 22:27:15 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="376382"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX180Cfp1Dgd8eHpkI3KvGl2GgMBnTjwQcsfg3VXSMButKw=="; posting-host="61bea730185dc00b7c39d5f27bd5f472"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ovo0BdG06sBflGEtJ5hI2goPpVo= sha256:euF7orc7wJYPtyexHs20LcBK8dA2wOvQPW1usyS9qmM=
	sha1:LI2Y9dJk4Ff2W9MiKAeiFB+q5c8= sha256:cAeiFHiPwNZSeIecLKM5WuqYqJHxpNRcKF/N2a5k0L8=
In-Reply-To: <11d54u2$863c$1@dont-email.me>
Content-Language: en-GB