Microcomputer Systems:Multiplication and Division of Floating Point Numbers

Multiplication and Division of Floating Point Numbers

Multiplication and division of floating point numbers are rather easy. Here are the steps:

• Add (or subtract) the exponents of the numbers.

• Multiply (or divide) the mantissa of the numbers.

• Correct the exponent.

• Normalize the number.

• The sign of the result is the EXOR of the signs of the two numbers.

Since the exponent is processed twice in the calculations, we have to subtract 127 from the exponent.

An example showing the multiplication of two floating point numbers follows.

Example 1.36

Show the decimal numbers 0.510 and 0.7510 in floating point and then calculate their multiplication.

Microcomputer Systems-0035

Microcomputer Systems-0036

 

Microcomputer Systems: Normalizing Floating Point Numbers and Converting a Decimal Number into Floating Point

Normalizing Floating Point Numbers

Floating point numbers are usually shown in normalized form. A normalized number has only one digit before the decimal point (a hidden number 1 is assumed before the decimal point).

To normalize a given floating point number, we have to move the decimal point repeatedly one digit to the left and increase the exponent after each move.

Some examples follow.

Microcomputer Systems-0032

Converting a Decimal Number into Floating Point

To convert a given decimal number into floating point, carry out the following steps:

• Write the number in binary.

• Normalize the number.

• Find the mantissa and the exponent.

• Write the number as a floating point number. Some examples follow:

Microcomputer Systems-0033

 

Microcomputer Systems:Converting Binary Numbers into Octal and Negative Numbers

Converting Binary Numbers into Octal

To convert a binary number into octal, arrange the number in groups of three and write the octal equivalent of each digit.

Microcomputer Systems-0020

Negative Numbers

The most significant bit of a binary number is usually used as the sign bit. By convention, for positive numbers this bit is 0, and for negative numbers this bit is 1. Figure 1.5 shows the 4-bit positive and negative numbers. The largest positive and negative numbers are þ7 and -8 respectively.

Microcomputer Systems-0021

To convert a positive number to negative, take the complement of the number and add 1. This process is also called the 2’s complement of the number.

Microcomputer Systems-0022

 

Microcomputer Systems:Adding Binary Numbers and Subtracting Binary Numbers

Adding Binary Numbers

The addition of binary numbers is similar to the addition of decimal numbers. Numbers in each column are added together with a possible carry from a previous column. The primitive addition operations are:

Microcomputer Systems-0023

Subtracting Binary Numbers

To subtract one binary number from another, convert the number to be subtracted into negative and then add the two numbers.

Microcomputer Systems-0024

 

Microcomputer Systems:Converting Decimal Numbers into Octal and Converting Octal Numbers into Binary

Converting Decimal Numbers into Octal

To convert a decimal number into octal, divide the number repeatedly by 8 and take the remainders. The first remainder is the LSD, and the last remainder is the MSD.

Microcomputer Systems-0016Microcomputer Systems-0017

Converting Octal Numbers into Binary

To convert an octal number into binary, write the 3-bit binary equivalent of each octal digit.

Microcomputer Systems-0018

Microcomputer Systems-0019

 

Microcomputer Systems:Converting Decimal Numbers into Hexadecimal and Converting Octal Numbers into Decimal

Converting Decimal Numbers into Hexadecimal

To convert a decimal number into hexadecimal, divide the number repeatedly by 16 and take the remainders. The first remainder is the LSD, and the last remainder is the MSD.

Microcomputer Systems-0014

Converting Octal Numbers into Decimal

To convert an octal number into decimal, calculate the sum of the powers of 8 of the number.

Microcomputer Systems-0015

 

Microcomputer Systems:Converting Decimal Numbers into Binary and Converting Binary Numbers into Hexadecimal

Converting Decimal Numbers into Binary

To convert a decimal number into binary, divide the number repeatedly by 2 and take the remainders. The first remainder is the least significant digit (LSD), and the last remainder is the most significant digit (MSD).

Microcomputer Systems-0007

Microcomputer Systems-0008

Converting Binary Numbers into Hexadecimal

To convert a binary number into hexadecimal, arrange the number in groups of four and find the hexadecimal equivalent of each group. If the number cannot be divided exactly into groups of four, insert zeros to the left of the number as needed so the number of digits are divisible by four.

Microcomputer Systems-0009

Microcomputer Systems-0010

 

Microcomputer Systems:Number Systems

Number Systems

To use a microprocessor or microcontroller efficiently requires a working knowledge of binary, decimal, and hexadecimal numbering systems. This section provides background information about these numbering systems for readers who are unfamiliar with them or do not know how to convert from one number system to another.

Number systems are classified according to their bases. The numbering system used in everyday life is base 10, or the decimal number system. The numbering system most

commonly used in microprocessor and microcontroller applications is base 16, or hexadecimal. Base 2, or binary, and base 8, or octal, number systems are also used.

Decimal Number System

The numbers in the decimal number system, of course, are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The subscript 10 indicates that a number is in decimal format. For example, the decimal number 235 is shown as 23510.

In general, a decimal number is represented as follows:

Microcomputer Systems-0003

Binary Number System

The binary number system consists of two numbers: 0 and 1. A subscript 2 indicates that a number is in binary format. For example, the binary number 1011 would be 10112.

In general, a binary number is represented as follows:

Microcomputer Systems-0004

Microcomputer Systems-0005