Hack #40. Count to a Million on Your Fingers
You can use binary arithmetic to count to more than a million on your fingers.
You probably already know that you can use Chisenbop [Hack #39] to count to 100 or more and do simple arithmetic on your fingers. If you switch from the decimal numeral system to binary, however, you can use your fingers to count to about 220, which is 1,048,576—more than a million!1
The Binary Numeral System
First, let's review the binary numeral system. (If you don't need a review, you can skip to the next section.)
The number system we use normally is called the decimal numeral system because it is based on powers of 10. For instance:
4309 = (4 x 1000) + (3 x 100) + (0 x 10) + (9 x 1)
Note that in the decimal system there are 10 digits: 0 to 9. Each position in a decimal number corresponds to a power of 10; for instance, 3 is in the hundreds position in the decimal number 4,309.
The binary numeral system is based on powers of 2, so there are only two digits, 0 and 1. These are referred to as bits, which is short for binary digit. Thus, in binary:
10011 = (1 x 16) + (0 x 8) + (0 x 4) + (1 x 2) + (1 x 1) = 19Tip
In this hack, I'll highlight binary numbers in bold, so you can tell them apart from ordinary decimal numbers. Without some convention, it would be impossible to tell whether a number like 10011, with only 1s and 0s, is binary or decimal.
Notice that because only 1 and 0 are used, there's no real multiplication here: we just add up the positions with 1s ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access