01 / 12
&& exists in the world of bits too
You have written a && b in JavaScript. It is true only when both are true and false otherwise. a || b is the opposite, true if either is true.
Carry that idea straight down to a single bit and you have logical operations. Nothing changes about what happens; you just write true as 1 and false as 0.
- Logical product (AND) … 1 only when both are 1. The same as
&& - Logical sum (OR) … 1 if either is 1. The same as
|| - Negation (NOT) … swaps 0 and 1. The same as
!
In the exam the notation changes. A・B is the logical product, A+B the logical sum, and a line over a letter shows negation. They wear the shapes of multiplication and addition, but treat the meanings as && and || as before.