<< Chapter < Page Chapter >> Page >

Using and storing binary numbers

In the previous section, we saw how the numbers 0 and 1 could represent `false' and `true' and could be used in decision making. Often we want to program a computer to count with numbers. To do this we need a way of writing any number using nothing other than 0 and 1. When written in this way, numbers are called binary numbers .

Binary Number System

A way of writing any number using only the digits 0 and 1.

Binary numbers

In normal (denary) numbers, we write 9+1 as 10. The fact that the `1' in 10 is the second digit from the right tells us that it actually means 10 and not 1. Similarly, the `3' in 365 represents 300 because it is the third digit from the right. You could write 365 as 3 × 100 + 6 × 10 + 5 . You will notice the pattern that the n th digit from the right represents 10 n - 1 . In binary, we use the n th digit from the right to represent 2 n - 1 . Thus 2 is written as 10 in binary. Similarly 2 2 = 4 is written as 100 in binary, and 2 3 = 8 is written as 1000 in binary.

Convert the binary number 10101 to its denary equivalent.

  1. We start on the right. The `1' on the right does indeed represent one. The next `1' is in the third place from the right, and represents 2 2 = 4 . The next `1' is in the fifth place from the right and represents 2 4 = 16 . Accordingly, the binary number 10101 represents 16+4+1 = 21 in denary notation.

Got questions? Get instant answers now!

Convert the decimal number 12 to its binary equivalent.

  1. Firstly we write 12 as a sum of powers of 2, so 12 = 8+4. In binary, eight is 1000, and four is 100. This means that twelve = eight + four must be 1000+100 = 1100 in binary. You could also write 12 as 1 × 8 + 1 × 4 + 0 × 2 + 0 × 1 = 1100 in binary.

Got questions? Get instant answers now!

Interesting fact

How do you write numbers as a sum of powers of two? The first power of two (the largest) is the largest power of two which is not larger than the number you are working with. In our last example, where we wanted to know what twelve was in binary, the largest power of two which is not larger than 12 is 8. Thus 12 = 8 + something. By arithmetic, the `something' must be 4, and the largest power of two not larger than this is 4 exactly. Thus 12 = 8 + 4, and we have finished.

A more complicated example would be to write one hundred in binary. The largest power of two not larger than 100 is 64 (1000000 in binary). Subtracting 64 from 100 leaves 36. The largest power of two not larger than 36 is 32 (100000 in binary). Removing this leaves a remainder of 4, which is a power of two itself (100 in binary). Thus one hundred is 64 + 32 + 4, or in binary 1000000 + 100000 + 100 = 1100100.

Once a number is written in binary, it can be represented using the low and high voltage levels of digital electronics. We demonstrate how this is done by showing you how an electronic counter works.

Counting circuits

To make a counter you need several `T flip flops', sometimes called `divide by two' circuits. A T flip flop is a digital circuit which swaps its output (from 0 to 1 or from 1 to 0) whenever the input changes from 1 to 0. When the input changes from 0 to 1 it doesn't change its output. It is called a flip flop because it changes (flips or flops) each time it receives a pulse.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Siyavula textbooks: grade 12 physical science. OpenStax CNX. Aug 03, 2011 Download for free at http://cnx.org/content/col11244/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Siyavula textbooks: grade 12 physical science' conversation and receive update notifications?

Ask