Floating point Arithmetic-1

A brief introduction on Data Representation inside computers

Data representation generally refers to the form in which data is stored, processed in a computing device and transmitted across computing devices. Data is stored, processed and transmitted in terms of 0’s and 1’s only. Data representation is machine dependent and depends on the architectural design of the computer.

Generally we have two types of data formats:

The below flowchart demonstrates the same in brief:

Data Representation and various formats
Data Representation and various formats

Floating point Arithmetic

Converting de-normalized value to normalized one
Converting de-normalized value to normalized one

IEEE formats

  1. According to IEEE standard 754; there are two kinds formats present:
Single Precision format
Single Precision format
Double precision format
Double precision format

Floating point data is stored in the memory with three fields of information:

  1. Sign field - It used to represent the sign of a data. 0 for positive and 1 for negative.
  2. Biased Exponent:
    • In memory, exponent is stored in a biased format rather than the signed format(2’s complement) because Most Significant bit(MSB) is already reserved for the mantissa sign, therefore 2’s complement exponent is not possible to represent the negative exponent.
    • Generally,

      BIASED EXPONENT = ACTUAL EXPONENT + BIAS

    • Bias is maximum possible positive exponent which depends on the format. Biased Exponent field or BEField is discussed below.

      $+2^{n - 1} - 1, n = BEFieldSize$

    • Below is the concept of preserving the sign of an exponent.
        if BiasedExponent > Bias
          then ActualExponent = "Positive"
        else
          ActualExponent = "Negative"
      
    • ExcessBias is another type of Bias where the Bias chosen is the center of the exponent range i.e.

      $\frac{2^n}{2}, n = BEFieldSize$

  3. Mantissa Field: It is used to represent the fraction.In memory, fraction is always stored in the normalized mantissa format. i.e. 1.bbbbb where b is either 0 or 1.

In the next post, I’ll try to share my learning on range of floating point number, special values used in floating point numbers and overflow and underflow conditions.