You are on page 1of 3

UNIT TWO

BINARY NUMBER REPRESENTATION


2.1 Number Representation in a Machine
The simplest numbers that we want to represent in the machine are the unsigned integers. These
are whole numbers without a sign, for example, 0, 1, 2, 3, … Decimal numbers are represented by using
the ten digits 0, 1, 2, … 9 in such a way that each digit is interpreted according to its position in the
number. Other number representations in a computer are binary, octal and hexadecimal. Binary numbers
are base two numbers which are represented by using the two digits 0 and 1, octal are base eight numbers
which uses the eight digits 0, 1, 2, …, 7 and hexadecimal numbers are base sixteen numbers which uses
the sixteen digits 0 – 9, A – F.

2.2 Binary Notation


Binary is a base 2 number system that uses two mutually exclusive states to represent
information. A binary number is made up of elements called bits where each bit can be in one of the
two possible states. Generally, we represent them with the numerals 1 and 0. We also talk about them
being true and false. In binary notation, numbers are represented through exponents of 2. For example,
11012 = (1 × 23) + (1 × 22) + (0 × 21) + (1 × 20) = (8) + (4) + (0) + (1) = 1310
Note that the subscript 2 on the number 1101 lets us know that the number is being represented
in base 2 rather than base 10. This representation shows how to convert numbers from base 2 into base
10. Consider another example, convert 1.1012 to base 10, we have
1.1012 = (1 × 20) + (1 × 2−1) + (0 × 2−2) + (1 × 2−3) = (1) + (1/2) + (0) + (1/8) = 1.62510

Conversion of Decimal into Binary and Binary into Decimal


To convert a decimal number into base 2, we find the highest power of two that does not exceed
the given number, and place a 1 in the corresponding position in the binary number. Then we repeat the
process with the remainder until the remainder is 0.
For example, consider the number 614. Since 29 = 512 is the largest power of 2 that does not
exceed 614, we place a 1 in the tenth position of the binary number, 1000000000. Continue with the
remainder, namely 102. We see that the highest power of 2 is now 6, as 26 = 64. Next, we place a 1 in
the seventh position: 1001000000. Continuing in this fashion we see that
61410 = 512 + 64 + 32 + 4 + 2 = 10011001102
Another alternative to convert base 10 into binary is to divide the number repeatedly by 2 until
the quotient is zero taking note of the remainder at each step. Then, write the remainders in reverse,
starting at the bottom and appending to the right each time. For example, to convert 61410 to binary, we
have
Quotient Remainder
614 ÷ 2 307 0
307 ÷ 2 153 1
153 ÷ 2 76 1
76 ÷ 2 38 0
38 ÷ 2 19 0
19 ÷ 2 9 1
9÷2 4 1
4÷2 2 0
2÷2 1 0
1÷2 0 1

Hence, 61410 = 100110011002


Converting fractions in base 10 to base 2 proceeds in a similar fashion. Take the fraction,
0.1640625. Using the same method, we see that since 2−3 = 0.125 and 2−2 = 0.25, we begin by placing
a 1 in the third position to the right of the decimal place: 0.001. The remainder is now 0.1640625 −
0.125 = 0.0390625, which holds the power 2−5 = 0.03125 with a remainder of 0.0078125. This
remainder is 2−7, and we have 0.00101012 represents the decimal fraction 0.1640625. In some cases,
the binary representation of a fraction may not have a finite number of digits.
Take the simple fraction, 0.1. Using the same method, we see that since 2−4 = 0.0625, we begin
by placing a 1 in the fourth position to the right of the decimal place. We see that 2−4 + 2−5 = 0.00625.
Continuing in this way we find that we have a repeating decimal representation: 0.1 =
0.00011001100110011..., where 0011 repeats forever. To convert a decimal number with a fractional
part into binary, we separately convert to binary the integer part and fractional part.

2.3 Signed and Unsigned Integers


Signed integers are stored in a computer using 2’s complement. They are numbers such as ˗3,
˗2, ˗1, 0, 1, 2. Let there be a number <0111>. Counting down gives the sequence shown in table 1.1.
Note that when the bits reach <0000>, the next lower number is <1111>, which we regard as the number
‘one less than zero’, or ˗1. These numbers may be evaluated by giving the bits the weight ˗8, 4, 2, 1.
This method of representing signed integers is called two’s complement representation. In general, the
left-most bit of a two’s complement number has a negative weight. For example, the signed integer
<p3p2p1p0> has the decimal value:
˗ 8.p3 + 4.p2 + 2.p1 + 1.p0
or ˗ 23.p3 + 22.p2 + 21.p1 + 20.p0
e.g. 1101 represents - 8.1 + 4.1 + 2.0 + 1.1 = (-3)
and 0010 represents - 8.0 + 4.0 + 2.1 + 1.0 = (+2)
Table 1.1: Four bits Counting down
<b3,b2,b1,b0> Interpretation as signed decimal number
0111 +7
0110 +6
0101 +5
0100 +4
0011 +3
0010 +2
0001 +1
0000 0
1111 -1
1110 -2
1101 -3
1100 -4
1011 -5
1010 -6
1001 -7
1000 -8

You might also like