Pages: <Previous  1    2    3    4    5    6    7    8    9    10    11  Next >

2 Representing data in the kitchen scales

2.2.2 Positve integers: binary numbers

Just as a denary number system uses ten different digits (0, 1, 2, 3, … 9), a binary number system uses two (0, 1).

Once again the idea of positional notation is important. You have just seen that the weightings which apply to the digits in a denary number are the exponents of ten. With binary numbers, where only two digits are used, the weightings applied to the digits are exponents of two.

The rightmost bit is given the weighting of 2°, which is 1. The next bit to the left is given a weighting of 21, which is 2, and so on.

Thus the 4-bit binary number 1101 represents:

The leftmost bit is called the most-significant bit (m.s.b.) and the rightmost bit is called the least-significant bit (l.s.b.)

Computers are designed to work with binary numbers, but denary numbers suit most people better. Humans therefore need to interpret the 4-bit binary number 1101 as follows:

(1 × 23) + (1 × 22) + (0 × 21) + (1 × 20)

which is 8 + 4 + 0+ 1 = 13 in denary.

Activity 3 (Self assessment)

What does the 4-bit binary number 1010 represent? To what denary number is it equal? What is its most-significant bit?

Now read the answer

Exactly the same principles can be applied to larger binary numbers. For example, in an 8-bit word the most-significant bit has a weighting of 27, which is 128. So 10110110 represents:

and equals 128 + 0 + 32 + 16 + 0+ 4 + 2 + 0, which is 182 in denary.

It is often convenient to number the bits in a binary word and to refer to the bits as ‘bit 5’ or ‘bit 2’. And the most convenient way of numbering the bits is to use the exponents in the weightings. So the bits are usually numbered as follows (for an 8-bit word):

7 6 5 4 3 2 1 0 bit number
27 26 25 24 23 22 21 20 weighting

This scheme means that the least-significant bit is bit 0 and the most-significant bit is bit 7.

Just as a space between groups of three digits in large numbers (e.g. 625 127) can make them easier to read, so spaces between groups of four bits can make binary numbers easier to read. I shall use spaces in this way. So I shall write, for example, 1001 1110 rather than 10011110. Note that the space is purely for convenience in reading the number; it does not affect the value of the number in any way, nor the way the computer handles it.

Activity 4 (Self assessment)

  1. To what denary number is the binary number 1100 0110 equal?
  2. In a 16-bit word, what is the weighting of the most-significant bit? What bit number should be allocated to this bit?
  3. To what denary number is the binary number 1000 0000 0000 0001 equal?

Note that Windows has a calculator (in Accessories) that will evaluate numbers like 210, 214, etc. You will need to choose Scientific from its View menu and then use the x^y key. For instance, to find 210 press 2 then x^y then 10 then =. You should get 1024.

Now read the answer

Counting in binary is very simple because there are only two possible digits. It proceeds as follows:

0
1
10
11
100
101
110
111
1000
etc.

Notice that when all the bits in any number are 1, the next higher number needs one more bit to represent it. This is exactly analogous to denary, where 999 is followed by 1000, which needs one more digit to represent it.

Activity 5 (Self assessment)

(a) What binary number follows
(i) 1 1111
(ii) 1 0111?
(b) What binary number precedes 1000 0000?

Now read the answer

Pages: <Previous  1    2    3    4    5    6    7    8    9    10    11  Next >