Re: &= for bools?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Mar 6, 1:40 pm, andy.johnst...@xxxxxxxxxxxxxxxxxx wrote:
"The & operator performs a bitwise logical AND operation on integral
operands and logical AND on bool operands."

Ah, I missed that, thanks.  Does this beg the question "Why is the &&
operator needed then?" ?

&& is a logical operator, and & is the bitwise operator.  The
expression on each side of && MUST evaluate to a boolean.  & can be
used with other number types.

Please read the thread to which you're responding before doing that.
As noted by Geoffrey, in C# what you say is wrong - operators & and |
are Boolean and not bitwise when applied to bool operands (and yes,
they can be used with bool).
.



Relevant Pages

  • Re: Boolean data type?
    ... What type is commonly used in C for playing around with boolean ... It might even make sense to store a boolean value in each bit ... (but you'll have to write your own bitwise masking and shifting code ... Assuming C99's _Bool is not available, ...
    (comp.lang.c)
  • Re: Pass by Reference as "essential" to swap method exposed as a l
    ... That code does not compile, as Booleans, can not be multiplied or added. ... Operator '*' cannot be applied to operands of type 'bool' and 'bool' C:\...\Program.cs 24 9 SwapCode ... Binary and base-2 numbering are synonomous. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: &= for bools?
    ... dealing with one bit (which is what a bool represents), it's a bitwise ... fact does not even consider bool an integral type (it can't be ... When the operands ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Why does FALSE return TRUE?
    ... Binary & operators are predefined for the integral types and bool. ... & computes the bitwise AND of its operands. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Conditionals with | vs ||
    ... applied to bool ...
    (microsoft.public.dotnet.languages.csharp)