Вы находитесь на странице: 1из 8

Digital Electronic Systems Unit 3

Hexadecimal and Floating Point Numbers


This section introduces hexadecimal numbers and outlines their relationship with other
number systems such as decimal and binary. It also introduces floating-point numbers that
are especially useful for representing very large and very small numbers in computing.

Hexadecimal Numbers
The Hexadecimal system is a number system based on sixteen symbols and is a compact way
of expressing binary numbers. It is frequently used in microprocessor and computer
applications. The system is based on the ten decimal digits and on the first six alphabetic
characters. The subscript 16 is used to indicate that a number is Hexadecimal, for example,
1016.
COUNT
zero
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen

DECIMAL
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

BINARY
02
12
102
112
1002
1012
1102
1112
10002
10012
10102
10112
11002
11012
11102
11112

HEXADECIMAL.
016
116
216
316
416
516
616
716
816
916
A16
B16
C16
D16
E16
F16

As can be seen a four digit binary number represents each Hexadecimal number. Counting in
Hexadecimal is very similar also:
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21.....

Binary to Hexadecimal conversion


Starting with the least significant bit take the binary number and group the digits into fours
and then convert them directly using the table above. If the most significant grouping is too
small, just add zeros to the left-hand side.
Ex 1: Convert the binary number 111001100011102 to a Hexadecimal number.

[398E16]

Ex 2: Express the 32-bit memory location 11011111100111000001010100001110 in


Hexadecimal.
[DF9C150E16]
1

Digital Electronic Systems Unit 3

Hexadecimal to Binary conversion


This is the reverse of the process for binary to hex, i.e. replace each Hexadecimal symbol
with the appropriate four binary digits (bits).
Ex 3: Convert the Hexadecimal number D2E816 to a binary number. [11010010111010002]
Hexadecimal to Decimal conversion
Multiply the decimal value of each hexadecimal digit by its weighting. The weighting are
increasing powers of 16, from right to left.
163=4096, 162=256, 161=16, 160=1.
Ex 4: Convert the Hexadecimal number B2F816 to a Decimal number.

[4581610]

Decimal to Hexadecimal conversion


This conversion process uses successive division by sixteen. The hexadecimal number is
generated from the remainders produced. The first remainder produced is the least significant
digit.
Ex 5: Convert the Decimal number 650 into a Hexadecimal number.

[28A16]

Floating-Point Numbers
The Floating-point number system, based on scientific notation, is capable of representing
very large and very small numbers without increasing the number of bits required. A
floating-point number consists of a three parts a sign bit, an exponent and a mantissa. The
mantissa represents the magnitude of the number and the exponent determines the position of
the decimal point.
Consider the decimal number
241,506,800
To represent this integer in floating-point, it must be normalised by moving the decimal point
to the left of all the digits leaving a fractional number (mantissa) and the exponent as follows:
0.2415068 10 9

Floating-point binary numbers


There are three different formats defined by ANSI/IEEE Standard 754-1985. These all have
the same basic format, except for the number of bits they use.
single precision (32 bits)
double precision (64 bits)
extended precision (80 bits)
We will restrict our discussion to the single-precision floating-point format.

Digital Electronic Systems Unit 3

Single-precision floating-point binary numbers


32 bits
Exponent (E)

S
1 bit

Mantissa (fraction, F)

8 bits

23 bits

sign bit

The range of floating point binary numbers that can be represented using single precision
(2 - 2 -23 ) 2127
~ 10 38.53

To evaluate a binary number, given the number in single precision floating point format
The Number in binary is given by:

1 S 1 F 2 E-127 2
where S is the sign bit (either 1 or 0)
F is the fractional part (mantissa) in binary
E is the biased exponent converted to decimal (The actual exponent is E-127)
Example
S
1

E
10010001

F
10001110001000000000000

The biased exponent, E is converted to decimal.


1

1 * 20 = 1 * 1
0 * 21 = 0 * 2
0 * 22 = 0 * 4
0 * 23 = 0 * 8
1 * 24 = 1 * 16
0 * 25 = 0 * 32
0 * 26 = 0 * 64
1 * 27 = 1 * 128
Sum
Substitute into the single precision floating point formula:
The number (in binary) is

1 1.1000111000 1 2
1 1.1000111000 1 2145127
1
1

18

=1
=0
=0
=0
= 16
=0
=0
= 128
= 145
10
10
10
10

10

10
10

10
10

Digital Electronic Systems Unit 3

Multiplying a binary number by 218 is the same as shifting the binary point 18 places to the
right. (This is analogous to shifting the decimal point n positions to the right when a decimal
number is multiplied by 10 n .) Therefore the number is
1100011100 010000000 2

This number can be converted to decimal, by determining the weights in all of the bit
positions where the binary digit is 1, and adding them together. The number in decimal is

218 217 213 212 211 2 7


40768010

10

Digital Electronic Systems Unit 3

SUMMARY
Number Systems:
Decimal (10 digits): 0,1,2,3,4,5,6,7,8,9
Binary (2 digits):
0,1
Hexadecimal (16 digits):
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Octal (8 digits):
0,1,2,3,4,5,6,7
Decimal to Binary
conversion

Successive division by 2 remainder

Binary to Decimal
conversion

Multiply each bit by it weight 2n and add

Binary Addition

02+02=02, 02+12=12, 12+02=12, 12+12=102, 12+12+12=112

Binary Subtraction

2s complement the number that you are subtracting and add

Binary Multiplication

02*02=02, 02*12=02, 12*02=02, 12*12=12 - same method is used


as in decimal long multiplication

Binary Division

Same method is used as in decimal long division

1s complement

Change all 12s to 02s and all 02s to 12s

2s complement

2s complement = 1s complement + 12

Octal to Decimal
conversion

Multiply each octal digit by it weight 8n and add

Decimal to Octal
conversion

Successive division by 8 remainder

Binary to Octal conversion

Group bits into threes and convert to Octal symbol

Octal to binary conversion

Replace each Octal symbol with equivalent 3 bits

Binary to Hexadecimal

Group bits into fours and convert to Hex symbol

Hexadecimal to Binary

Replace each Hex symbol with equivalent 4 bits

Hexadecimal to Decimal

Multiply each Hex digit by it weight 16n and add

Decimal to Hexadecimal

Successive division by 16 remainder

Digital Electronic Systems Unit 3

Number Systems Revision Exercises


Decimal Numbers
Ex. 6
What is the weight of the digit 6 in each of the decimal numbers?
(a)
1,386
(b)
54,692
(c)
671,920
Ex. 7
Express each of the following decimal numbers as a power of ten.
(a)
10
(b)
100
(c)
10,000
(d)
1,000,000
Binary Numbers
Ex. 8
Convert the following binary numbers to decimal.
(a)
112
(b)
1002
(c)
10112
(d)
111112

[310]
[410]
[1110]
[3110]

Ex. 9
Convert the following binary numbers to decimal.
(a)
110011.112
(b)
1110001.00012
(c)
1011010.10102

[51.7510]
[113.062510]
[90.62510]

Ex. 10
What is the highest decimal number that can be represented by seven bits?
Ex. 11
How many bits are required to represent the following decimal numbers?
(a)
17
[5]
(b)
49
[6]
(c)
132
[8]
(d)
205
[8]

Digital Electronic Systems Unit 3

Ex. 12
Generate the binary sequence for the decimal sequence from 64 to 75.
Ex. 13
Convert the following decimal numbers to binary.
(a)
17
(b)
59
(c)
73
(d)
186

[100012]
[1110112]
[10010012]
[101110102]

Ex. 14
Convert each of the following decimal numbers to binary (to 6 binary places).
(a)
0.98
[0.1111102]
(b)
0.347
[0.0101102]
(c)
186.9028
[10111010.1110012]
Ex. 15
Determine the 1s complement of each binary number (assume 8-bit 1s complement).
110101112
(a)
11101012
(b)
Ex. 16
Determine the 2s complement of each binary number (assume 8-bit 2s complement).
110101112
(a)
11101012
(b)
Ex. 17
Express each decimal number in binary as an 8-bit number in 2s complement form.
(a)
68
[101111002]
(b)
+101
[011001012]
(c)
125
[100000112]
Ex. 18
Determine the decimal value of each signed binary number (assume 8-bit 2s
complement).
(a)
100110012
[-10310]
(b)
011101002
[11610]
(c)
101111112
[-6510]
Binary Arithmetic
Ex. 19
Add the following binary numbers.
(a)
10012 + 1012
(b)
11012 + 10112

[11102]
[110002]

Digital Electronic Systems Unit 3

Ex. 20
Convert each pair of decimal numbers to 8-bit binary in 2s complement form and
add.
(a)
33 and 15
[001100002]
(b)
56 and 27
[000111012]
(c)
46 and 25
[-000101012]
(d)
110 and 84
[OVERFLOW]
Ex. 21
Perform each addition (Each number is in 8-bit 2s complement form.)
(a)
100011002 + 001110012
[001110112]
(b)
110110012 + 111001112
[010000002]
Ex. 22
Perform each subtraction using 8-bit 2s complement.
(a)
001100112 000100002
(b)
011001012 111010002

[001000112]
[011111012]

Ex. 23
Multiply 011010102 by 111100012 (Each number is in 8-bit 2s complement form.)
[1001110010102 in 12-bit 2s complement form]
Ex. 24
Divide 01000100 by 00011001 (Each number is in 8-bit 2s complement form.)
[10.101110000101000111102 recurring]
Hexadecimal Numbers
Ex. 25
Convert each Hexadecimal number to binary
(a)
5916
(b)
FB1716

[010110012]
[11111011000101112]

Convert each binary number to Hexadecimal


(a)
101112
(b)
1001100000102

[1716]
[98216]

Convert each hexadecimal number to decimal


(a)
EB16
(b)
5C216

[23510]
[147410]

Convert each decimal number to hexadecimal.


(a)
52
(b)
284

[3416]
[11C16]

Ex. 26

Ex. 27

Ex. 28

Вам также может понравиться