Docsity

Floating point Arithmetic, Summaries of Computer Architecture and Organization

Partial preview of the text

Download Floating point Arithmetic and more Summaries Computer Architecture and Organization in PDF only on Docsity!

Floating point arithmetic

Floating Point Number Representation

  • ยฑ mantissa (or) significant ร— Base ยฑExponent
  • (Ex.) 0. 00000000005=0.5 ร— 10
  • 10
  • 50000000000=5 ร— 10 10
  • Rules:
    1. The integer part should be zero
    2. 0.d 1 d 2 โ€ฆ. d n ร— Base ยฑExponent then d 1 >0 and all d 2 โ€ฆ. d n โ‰ฅ
  • Two representation techniques
    • Single precision (32 bit)
    • Double precision (64 bit)

Floating point arithmetic Operations: Add &

Sub

  • Steps:
    1. Compare the magnitude of the two exponents and make alignment to the number with smaller magnitude of exponent.
    2. Perform the Addition / Subtraction
    3. Perform the normalization by shifting the resulting mantissa and adjusting the resulting exponent
  • Example
    • Add 1.1100 ร— 2 4 and 1.1000 ร— 2 2
    1. Alignment: 1.1000 ร— 2 2 has to be aligned to 0.0110 ร— 2 4
    2. Add: Add two numbers to get 10.0010 ร— 2 4
    3. Normalize: Final result is 0.1000 ร— 2 6

Algorithm

Floating point arithmetic: Multiplication

  • Multiplication of a pair of Floating Point numbers

๐‘ฅ

ร— 2

๐‘Ž

and Y = ๐‘š

๐‘ฆ

ร— 2

๐‘

is represented as

XY = ๐‘š

๐‘ฅ

ร— ๐‘š

๐‘ฆ

ร— 2

๐‘Ž+๐‘

  • Algorithm
    1. Compute the exponent of the product by adding the exponent together.
    2. Multiply two mantissas
    3. Normalize and round the final product
  • Example: Multiply X=1.000 ร— 2
    • 2 and Y=-1.010 ร— 2 - 1
    • Add exponents: (-2)+(-1)=(-3)
    • Multiply Mantissa: 1.000 ร— - 1.010=-1.
    • After normalizing product is: - 1.0100ร— 2
      • 3

Floating point arithmetic: Division

  • Division of a pair of Floating Point numbers ๐‘‹ = ๐‘š ๐‘ฅ

ร— 2

๐‘Ž

and Y = ๐‘š

๐‘ฆ

ร— 2

๐‘

is represented as

X/Y = ๐‘š๐‘ฅ/๐‘š๐‘ฆ ร— 2

๐‘Žโˆ’๐‘

  • Algorithm
    1. Compute the exponent of the result by subtracting the exponent together.
    2. Divide the mantissa and decide the sign of the result
    3. Normalize and round the final result
  • Example: Divide X=1.0000 ร— 2
    • 2 and Y=-1.0100 ร— 2 - 1
    • Subtract exponents: (-2)-(-1)=(-1)
    • Divide Mantissa: 1.0000 /-1.0100=-0.
    • After normalizing product is: - 0. 1101 ร— 2
      • 1

Chopping

The result is the unbiased approximation

IEEE 754 Floating Point Representation

What is the decimal equivalent of the floating

point number 40400000H

โ€ข 40400000H = 0100 0000 01000 0000 0000 0000 0000 0000
S E M
  • s=0 E=128 M=0.