[OT] help w/ bitwise comparison operators

Kevin D. Clark kclark at CetaceanNetworks.com
Fri Mar 21 14:39:14 EST 2003


Erik Price <eprice at ptc.com> writes:

> You're right, thanks for the correction.  I mis-read the text.  &, |,
> &&, and || are all -logical- operators, and what I said above is true
> only for boolean values.  The short-circuit logical operators (&& and
> ||) won't compile if they are used with integral operands, though the
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                       
> bitwise operators (& and |) will.

OK, now we're really splitting hairs, and I suspect that you mistyped
anyways, but just to be clear, the logical operators work on any
scalar type.

For example, these are all legal in C:

        1 && 2
        2 && 3.14
        2.718 && "hello"
        'b' && &foo;

Etc.

--kevin
-- 
When you're playing with bits, expect to get bitten.




More information about the gnhlug-discuss mailing list