user7728: Since the maximum value of a float variable is 3.4028235E+38, shouldn't it represented with 128 bits instead of 32? (2^128=3.4028235E+38).

user4143: Another way of looking at it is that a float variable is actually a list of 4294967296 numbers. That's far less than the possible range of numbers and fractions that a float can represent, so only a subset of the numbers are actually represented. Any number you try and use that's not in that list of numbers is rounded to the nearest one.

user368: No, because IEEE 754 floats use a decimative compressed format. 64-bit floats allocate 1 bit to the sign, 11 bits to the exponent, and 52 bits to the mantissa, 32-bit floats allocate 1, 8, and 23, and so on.
You convert from it by adding an offset to the exponent, multiplying the mantissa by the exponent to the power of 2, and then applying the sign.

user7508: Just adding a little piece of information to the previous answers: it's
worth noting that a float can represent exactly all integers from
−224 to +224 (i.e. ±16777216).
The next integer, namely 16777217, is not representable as a float. A
calculation giving this value would suffer a rounding error.

user18600: No, it is not integer, so you cannot calculate it that way. It have floating point (not in fixed place).
It is stored as
1.significand x 2 ^ exponent.
It takes one bit for sign (+/-), 23 for significand (0 is not stored it is implicit) and 8 more for exponent.
Because of this, you have fixed precision (number of significant digits) for very large numbers and also for numbers which are close to zero.
You have it all explained here:
https://en.wikipedia.org/wiki/Single-precision_floating-point_format

7728: <p>Since the maximum value of a float variable is 3.4028235E+38, shouldn't it represented with 128 bits instead of 32? <em>(2^128=3.4028235E+38)</em>.</p>
 4143: <p>Another way of looking at it is that a float variable is actually a list of 4294967296 numbers. That's far less than the possible range of numbers and fractions that a float can represent, so only a subset of the numbers are actually represented. Any number you try and use that's not in that list of numbers is rounded to the nearest one.</p>
 368: <p>No, because <a href="https://en.wikipedia.org/wiki/IEEE_floating_point" rel="nofollow">IEEE 754 floats</a> use a decimative compressed format. 64-bit floats allocate 1 bit to the sign, 11 bits to the exponent, and 52 bits to the mantissa, 32-bit floats allocate 1, 8, and 23, and so on.</p>

<p>You convert from it by adding an offset to the exponent, multiplying the mantissa by the exponent to the power of 2, and then applying the sign.</p>
 7508: <p>Just adding a little piece of information to the previous answers: it's
worth noting that a float can represent <em>exactly</em> all integers from
−2<sup>24</sup> to +2<sup>24</sup> (i.e. ±16777216).</p>

<p>The next integer, namely 16777217, is not representable as a float. A
calculation giving this value would suffer a rounding error.</p>
 18600: <p>No, it is not integer, so you cannot calculate it that way. It have floating point (not in fixed place).</p>

<p>It is stored as</p>

<p><strong>1.significand x 2 ^ exponent.</strong></p>

<p>It takes one bit for sign (+/-), 23 for significand (0 is not stored it is implicit) and 8 more for exponent.</p>

<p>Because of this, you have fixed precision (number of significant digits) for very large numbers and also for numbers which are close to zero.</p>

<p>You have it all explained here:
<a href="https://en.wikipedia.org/wiki/Single-precision_floating-point_format" rel="nofollow">https://en.wikipedia.org/wiki/Single-precision_floating-point_format</a></p>
