2. Integer and floating point number representation and operations

Exercise outline

  1. integer representation, addition, subtraction, multiplication, division
  2. real number represetation (in IEEE 754)
  3. 1st homework

What topics should I repeat before this exercise

  1. logic operations (and, or, invert, rotation, …)
  2. two's complement code and IEEE 754.
  3. to understand the program from the last class.

What shall we do on the second exercise

The aim of today's exercise is representation of real and integer numbers in computer and arithmetical operations with them.


  1. Integer addition and subtraction in two's complement representation
    • add and subtract two integer numbers. For example 5+(-6) and 5-(-6).
    • repeat the operations with different numbers and check your results with the computer program from the first exercise.
    • When the underflow and overflow can happen? How can we detect, that it had occured?
  2. Integer multiplication
    • multiply two integers, For example 7*6.
    • is there any difference when multiplying negative numbers? (e.g. -7*6, (-7)*(-6), etc…)
    • show how to speed-up the multiplier? (use many adders instead repetitively using one).
  3. Integer division
    • divide integers 42/7, 43/7
    • does the algorithm change when we use negative numbers?
  4. Real number representation (IEEE 754)
    • binary representation of real numbers (float - 32bit, double - 64bit)
    • show binary representation of -0.75. Check your result with program from the last exercise.
    • find decimal number for float binary number 0xC0A00000 in IEEE754.
    • explain who to add numbers 9.999*10^1 and 1.1610*10^(-1) in decimal representation. Assume that it is possible to store only 4 digits in mantisa and 2 digits in exponent.
      • Hint: 1) align numbers 2) addition 3) normalization 4) round numbers.
    • in binary representation add 0.5 and -0.4375
    • in decimal representation show multiplication of 1.110*10^10 * 9.200*10^(-5)
    • in binary representation multiply 0.5 and -0.4375


* gcc/config/fp-bit.c - Implementation of float point operations with real numbers using fixed point arithmetic as used in GCC compiler. Used on processors without hardware floating point support.

courses/b35apo/en/tutorials/02/start.txt · Last modified: 2018/02/11 17:30 (external edit)