1

I have two numbers represented in floating point:

$A: 10101001001110000000000000000000$

$B: 01000011011000000000000000000000$

For $A$ I know $e=82$ and for $B$, $e=134$ ($e$=exponent), but I don't know how to subtract these numbers in floating point.

How should we make the subtraction?

John D
  • 545

1 Answers1

1

Interpreting the floating point bits

A: 1 01010010 01110000000000000000000

B: 0 10000110 11000000000000000000000

gives indeed $$ A=-2^{82-127}\cdot(1.0111)_2 \\ B=+2^{134-127}\cdot(1.1100)_2 $$ The exponent difference is so large that when shifting both numbers towards the larger exponent, $A$ gets shifted/rounded to zero. The operation is thus in this case trivial.

Lutz Lehmann
  • 126,666
  • Then, the answer for subtraction is B. ok. but - could you explain about the difference between exponent. we got difference 52 in this case, then algorithm says shift (left or right?) 52 times to larger exponent (134) and then make regular subtraction of binary numbers? if the exponent subtracter was 5 for example, then we shift 5 times and what the next step? regular subtraction of binary numbers? – John D Jul 16 '20 at 20:43
  • $2^{-3}(1.011)_2=(0.001011)_2$ as usual. Note that the stored mantissa only has $1+23$ bits, any shift to the right by more than $25$ bit gives a number that does not influence the calculation as it rounds to zero in most rounding modes. Note that the subtraction operation is basically an addition due to the opposite signs of the operands. – Lutz Lehmann Jul 17 '20 at 10:07