r/javahelp • u/Fr4nkWh1te • Jul 13 '19
Are non short-circuit logical operators ( | & ) refered to as bitwise operators?
That's one thing that confuses me.
From my research online, it seems that | and & are referred to as "bitwise operators", even if they are used as logical operators between 2 boolean expressions. What do they have to do with bitwise operations, besides using the same operator symbols?
Here an example:
The non-bitwise operators && and || are short-circuit operators. In other words, with &&, if the LHS is false, the RHS will never be evaluated; with || if the LHS is true, then the RHS will never be evaluated. On the other hand, the bitwise operators & and | are non-short-circuit, and will always evaluate both the LHS and the RHS.
18
Upvotes
0
u/[deleted] Jul 13 '19
[deleted]