From Logic Operators to Calculations

Combining trivial Boolean logic operations can lead to a number of surprising capabilities, such as the ability to perform arithmetic operations on binary representations of numbers. This is where things get interesting.

A set of XOR and AND gates, for example, can be used to increase an input number by 1, and this is the first step on our way toward addition. Figure 2-3 shows a design for a counter, based on this concept.

Ah, a new term! XOR is yet another “convenient” Boolean logic operator that is true only when one of its operands is true. In this regard, it is closer to the usual meaning of “or” in English. XOR is often used to simplify notation, but otherwise easy to implement by other means, by recombining ...

Get Silence on the Wire now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.