2

I am trying to understand the following:

For example the number $-2.5 = -1*1.25*2^1$ is strored as:
$S = 1$, Exponent $= 1+127 = 128$, Mantissa = $0.25 $

This got me. How do you connect all these numbers to yield $-2.5$ ?

abkds
  • 2,210
oz123
  • 151

2 Answers2

3

If you are given a sign bit $S$, 127-offset exponent $e$, and mantissa $m$, you calculate the value as

$$(-1)^S2^{e - 127}(1 + m)$$

So for your values $S=1$, $e=128$, and $m=0.25$,

$$(-1)^1 2^{128-127}(1 + 0.25) = -2.5$$

NovaDenizen
  • 4,216
  • 15
  • 23
1

Actually, the number $-2.5$ is stored according to the division 32=1+8+23 as

1 | 1000 0000 | 0100 0000 0000 0000 0000 000

according to the bit pattern that you found, i.e., $-2.5=(-1)^1\cdot 2^{128-127}\cdot (1.01)_2$.

Lutz Lehmann
  • 126,666