How IEEE-754 Floating-Point Numbers Work

Let's say I have this:

float i = 1.5 

in binary format, this float is represented as:

0 01111111 10000000000000000000000

I broke the binary to represent fragments of "signed", "exponent" and "fraction".

What I do not understand is how it means 1.5.

The exponent is 0 after subtracting the offset (127 - 127), and the part with the implicit lead is 1.1.

How 1.1 scales with nothing = 1.5 ???

+9
floating-point types ieee-754
source share
4 answers

First think about the decimal (base 10): 643.72:

  • (6 * 10 2 ) +
  • (4 * 10 1 ) +
  • (3 * 10 0 ) +
  • (7 * 10 -1 ) +
  • (2 * 10 -2 )

or 600 + 40 + 3 + 7/10 + 2/100.

Since n 0 is always 1, n -1 matches 1 / n (for a specific case) and n -m matches 1 / n m (for a more general case).

Similarly, the binary number 1.1:

  • (1 * 2 0 ) +
  • (1 * 2 -1 )

moreover, 2 0 is one and 2 -1 is half.

In the decimal value, the numbers to the left of the decimal point have factors of 1, 10, 100, etc., the heading to the left of the decimal point and 1/10, 1/100, 1/1000 the heading to the right (i.e. 10 2 10 1 10 0 decimal point, 10 -1 10 -2 , ...).

In the base-2, the numbers to the left of the binary point have the factors 1, 2, 4, 8, 16, etc., the title on the left. The numbers on the right have factors 1/2, 1/4, 1/8, etc., Directing to the right.

So, for example, a binary number:

 101.00101 | | | | | | | +- 1/32 | | +--- 1/8 | +------- 1 +--------- 4 

equivalent to:

 4 + 1 + 1/8 + 1/32 

or

  5 5 -- 32 
+25
source share

1.1 in binary terms is 1 +.5 = 1.5

+7
source share

Mantissa is significantly shifted in terms of indicator.

 3 in binary is 0011 3>>1 in binary, equal to 3/2, is 0001.1 
+1
source share

You want to read it - IEEE 754-1985

Actual standard here

0
source share

All Articles