Number systems conversions, Exercises of Digital Systems Design

Binary number system and conversions

Typology: Exercises

2016/2017

Uploaded on 09/06/2017

gilbert-sigala
gilbert-sigala 🇧🇼

1 document

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
will have only two numerals, namely 0 and 1.
Consider the number (N)
2
= (11100110)
2
.
It is an eight digit binary number. The binary digits are also known as bits.
Consequently the above number would be referred to as an 8-bit number. Its
decimal value is given by
(N)
2
= 1 x 2
7
+ 1 x 2
6
+ 1 x 2
5
+ 0 x 2
4
+ 0 x 2
3
+ 1 x 2
2
+ 1 x 2
1
+ 0 x 2
0
= 128 + 64 + 32 + 0 + 0 + 4 + 2 + 0 = (230)
10
Consider a binary fractional number (N)
2
= 101.101.
Its decimal value is given by
(N)
2
= 1 x 2
2
+ 0 x 2
1
+ 1 x 2
0
+ 1 x 2
-1
+ 0 x 2
-2
+ 1 x 2
-3
= 4 + 0 + 1 +
1
2
+ 0 +
1
8
= 5 + 0.5 + 0.125 = (5.625)
10
From here on we consider any number without its radix specifically mentioned, as a
decimal number.
With the radix value of 2, the binary number system requires very long strings of 1s
and 0s to represent a given number. Some of the problems associated with handling
large strings of binary digits may be eased by grouping them into three digits or four
digits. We can use the following groupings.
Octal (radix 8 to group three binary digits)
Hexadecimal (radix 16 to group four binary digits)
In the octal number system the digits will have one of the following eight values 0, 1,
2, 3, 4, 5, 6 and 7.
In the hexadecimal system we have one of the sixteen values 0 through 15.
However, the decimal values from 10 to 15 will be represented by alphabet A (=10),
B (=11), C (=12), D (=13), E (=14) and F (=15).
Conversion of a binary number to an octal number or a hexadecimal number is very
simple, as it requires simple grouping of the binary digits into groups of three or
four. Consider the binary number 11011011. It may be converted into octal or
hexadecimal numbers as
(11011001)
2
= (011) (011) (001) = (331)
8
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Number systems conversions and more Exercises Digital Systems Design in PDF only on Docsity!

will have only two numerals, namely 0 and 1.

Consider the number (N) 2 = (11100110) 2.

It is an eight digit binary number. The binary digits are also known as bits.

Consequently the above number would be referred to as an 8-bit number. Its

decimal value is given by

(N) 2 = 1 x 2 7 + 1 x 2^6 + 1 x 2^5 + 0 x 2 4 + 0 x 2 3 + 1 x 2^2 + 1 x 2^1 + 0 x 2 0

Consider a binary fractional number (N) 2 = 101.101.

Its decimal value is given by

(N) 2 = 1 x 2^2 + 0 x 2^1 + 1 x 2^0 + 1 x 2-1^ + 0 x 2-2^ + 1 x 2-

1

1 8

From here on we consider any number without its radix specifically mentioned, as a

decimal number.

With the radix value of 2, the binary number system requires very long strings of 1s

and 0s to represent a given number. Some of the problems associated with handling

large strings of binary digits may be eased by grouping them into three digits or four

digits. We can use the following groupings.

Octal (radix 8 to group three binary digits)

Hexadecimal (radix 16 to group four binary digits)

In the octal number system the digits will have one of the following eight values 0, 1,

2, 3, 4, 5, 6 and 7.

In the hexadecimal system we have one of the sixteen values 0 through 15.

However, the decimal values from 10 to 15 will be represented by alphabet A (=10),

B (=11), C (=12), D (=13), E (=14) and F (=15).

Conversion of a binary number to an octal number or a hexadecimal number is very

simple, as it requires simple grouping of the binary digits into groups of three or

four. Consider the binary number 11011011. It may be converted into octal or

hexadecimal numbers as

= (1101) (1001) = (D9) 16

Note that adding a leading zero does not alter the value of the number. Similarly for

grouping the digits in the fractional part of a binary number, trailing zeros may be

added without changing the value of the number.

Quotient Remainder

Quotient Remainder

42 16 2 A

(678) 10 = (2A6) 16

Representation of Negative Numbers

In our traditional arithmetic we use the “+” sign before a number to indicate it as a positive number and a “-” sign to indicate it as a negative number. We usually omit the sign before the number if it is positive. This method of representation of numbers is called “sign-magnitude” representation. But using “+” and “-” signs on a computer is not convenient, and it becomes necessary to have some other convention to represent the signed numbers. We replace “+” sign with “0” and “-” with “1”. These two symbols already exist in the binary system. Consider the following examples:

(+1100101) 2 (01100101) 2 (+101.001) 2 (0101.001) 2 (-10010) 2 (110010) 2 (-110.101) 2 (1110.101) (^2)

In the sign-magnitude representation of binary numbers the first digit is always treated separately. Therefore, in working with the signed binary numbers in sign-magnitude form the leading zeros should not be ignored. However, the leading zeros can be ignored after the sign bit is separated. For example,

1000101.11 = - 101.

While the sign-magnitude representation of signed numbers appears to be natural extension of the traditional arithmetic, the arithmetic operations with signed numbers in this form are not that very convenient, either for implementation on the computer or for hardware implementation. There are two other methods of representing signed numbers.

Diminished Radix Complement (DRC) or (r-1)-complement Radix Complement (RX) or r-complement

When the numbers are in binary form

Diminished Radix Complement will be known as “one’s-complement” Radix complement will be known as “two’s-complement”.

If this representation is extended to the decimal numbers they will be known as 9’s- complement and 10’s-complement respectively.

One’s Complement Representation

Let A be an n-bit signed binary number in one’s complement form.

The most significant bit represents the sign. If it is a “0” the number is positive and if it is a “1” the number is negative.

This relationship can be used to determine one’s complement representation of negative decimal numbers.

Example 1 : What is one’s complement binary representation of decimal number -75?

Decimal number 75 requires 7 bits to represent its magnitude in the binary form. One additional bit is needed to represent the sign. Therefore,

one’s complement representation of 75 = 01001011 one’s complement representation of -75 = 10110100

Two’s Complement Representation

Let A be an n-bit signed binary number in two’s complement form.

The most significant bit represents the sign. If it is a “0”, the number is positive, and if it is “1” the number is negative. The remaining (n-1) bits represent the magnitude, but not as a simple weighted number.

Consider the following two’s complement numbers and their decimal equivalents:

0111111 + 63 0000110 + 6 0000000 + 0 1111010 - 6 1000001 - 63 1000000 - 64

There is only one representation of “0”, namely 000....0.

From these illustrations we observe

If most significant bit (MSD) is zero the remaining (n-1) bits directly indicate the magnitude.

If the MSD is 1, the magnitude of the number is obtained by taking the complement of all the remaining (n-1) bits and adding a 1.

Consider the two’s complement representation of -6.

We assume we are representing it as a 7-bit number. Leave the sign bit. The remaining bits are 111010. These have to be complemented (that is

  1. and a 1 has to be added (that is 000101 + 1 = 000110 = 6).

In the example shown above a 7-bit number can cover the range from +63 to -64. In general an n-bit number has a range from + (2n-1^ - 1) to - (2 n-1^ ) with one representation for zero.

The representation also suggests that if A is an integer in two’s complement form, then

Two’s complement of A = -A

Two’s complement of a number is obtained by complementing all the digits and adding ‘1’ to the LSB.

This relationship can be extended to fractions as well.

If A = 0.101 (+0.625) 10 , then the two’s complement of A is 1.011, which is two’s complement representation of (-0.625) 10.

Similarly consider the case of a mixed number.

A = 010011.0101 (+19.3125) 10 Two’s complement of A = 101100.1011 (- 19.3125) 10

This relationship can be used to determine two’s complement representation of negative decimal numbers.

Example 2 : What is two’s complement binary representation of decimal number -75?

Decimal number 75 requires 7 bits to represent its magnitude in the binary form. One additional bit is needed to represent the sign. Therefore,

Two’s complement representation of 75 = 01001011 Two’s complement representation of -75 = 10110101

M1L1: Number Systems Problems

  1. Perform the following number system conversions: (a) 10110111 2 =? 10 (b) 567410 =? (^2) (c) 10011100 2 =? 8 (d) 24538 =? (^2) (e) 111100010 2 =? 16 (f) 6893410 =? (^2) (g) 10101.001 2 =? 10 (h) 6FAB7 16 =? 10 (i) 11101.101 2 =? 8 (j) 56238 16 =? (^2)
  2. Convert the following hexadecimal numbers into binary and octal numbers (a) 78AD (b) DA643 (c) EDC (d) 3245 (e) 68912 (f) AF4D
  3. Convert the following octal numbers into binary and hexadecimal numbers (a) 7643 (b) 2643 (c) 1034 (d) 3245 (e) 6712 (f) 7512
  4. Convert the following numbers into binary: (a) 1236 10 (b) 2349 10 (c) 345.275 10 (d) 4567 8 (e) 45.65 8 (f) 145.23 8 (g) ADF5 16 (h) AD.F3 16 (i) 12.DA 16
  5. What is the range of unsigned decimal values that can be represented by 8 bits?
  6. What is the range of signed decimal values that can be represented by 8 bits?
  7. How many bits are required to represent decimal values ranging from 75 to -75?
  8. Represent each of the following values as a 6-bit signed binary number in one’s complement and two’s complement forms. (a) 28 (b) -21 (c) -5 (d) -
  9. Determine the decimal equivalent of two’s complement numbers given below: (a) 1010101 (b) 0111011 (c) 11100010