Simple example, 2 bits:

int: [0 1 2 3] (available codes)

float: [-1 -0.25 0.25 1] (available codes)

What is the _number_ of shades available in each? The answer is 4, 2^2 for both. What kind of data can be stored within them? Basically any data. But floating point is a lot easier to work with for many kinds of data and operations. The distribution of available numbers and the quantization error makes a lot of sense for many tasks.

No, it doesn't work like that. Your example is just a wierdly shifted encoding.

A simple illustration would be 8 bits. The integer version would be 0 ... 255. The floating point version might be 4 bits main part (mantissa or significand) plus 4 bits exponent for a total of 8 bits. But the exponent would vary from 0 to 15 (four bits). The mantissa represents a fraction, with a hidden bit (always included in the math) in what would be the fifth bit (most significant bit). That is added to the fraction, so the fraction ranges from 1.0 to nearly 2.0. But if you put a 1 in the least bit of the exponent, then you multiply those values by two. So:

0000 0000 = 1.0 x 2^0 = 1.0 x 1 = 1.0

0001 0000 = 1 1/16 x 2^0 = 1.0625

1111 0000 = 1 15/16 x 2^0 = 1.9375

0000 0001 = 1.0 x 2^1 = 1.0 x 2 = 2.0

0001 0001 = 1.0625 x 2 = 2.125

1111 0001 = 1.9375 x 2 = 3.875

0000 1000 = 1.0 x 2^8 = 1.0 x 128 = 128

0001 1000 = 1 1/16 x 128 = 1.0625 x 128 = 136

1111 1000 = 1 15/16 x 128 = 1.9375 x 128 = 248

0000 1111 = 1.0 x 2^15 = 1.0 x 32768 = 32768

0001 1111 = 1.0625 x 32768 = 34816

1111 1111 = 1.9375 x 32768 = 63488

So you can see that an 8 bit floating point number (in 4,4 form) has a much greater range than an 8 bit integer: 0 ... 63488 versus 0 ... 255.

That is why the floating point numbers used for 32 bit floating point colour have three 8 bit mantissas and an 8 bit exponent. This is how they can store a huge dynamic range.

Yes, it does have to be compressed for viewing, which can lead to some posterization problems if not done well, but it does allow you to render or capture a scene with a high dynamic range and display it in a meaningful and sometimes beautiful way.