Here: http://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.2.3 it says that:
The finite nonzero values of any floating-point value set can all be expressed in the form
s · m · 2^(e - N + 1)
, wheres
is+1
or-1
,m
is a positive integer less than2^N
, ande
is an integer betweenEmin = -(2^(K-1)-2)
andEmax = 2^(K-1)-1
, inclusive, and whereN
andK
are parameters that depend on the value set.
and there is a table below:
Parameter float
N 24
K 8
So let's say N = 24
and K = 8
then we can have the following value from the formula:
s · 2^N · 2^(2^(K-1)-1 - N + 1)
which gives us according to values specified in the table:
s * 2^24 * 2^(127 - 24)
which is equal to s * 2^127
. But float has only 32 bits so it's not possible to store in it such a big number.
So it's obvious that initial formula should be read in a different way. How then? Also in javadoc for Float max value: http://docs.oracle.com/javase/7/docs/api/java/lang/Float.html#MAX_VALUE
it says:
A constant holding the largest positive finite value of type float,
(2-2^-23)·2^127
This also doesn't make sense, as resulting value is much larger than 2^32 - which is possible the biggest value that can be stored in float variable. So again, I'm misreading this notation. So how it should be read?