Float.intBitsToFloat

Returns the {@code float} value corresponding to a given bit representation. The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "single format" bit layout.

<p>If the argument is {@code 0x7f800000}, the result is positive infinity.

<p>If the argument is {@code 0xff800000}, the result is negative infinity.

<p>If the argument is any value in the range {@code 0x7f800001} through {@code 0x7fffffff} or in the range {@code 0xff800001} through {@code 0xffffffff}, the result is a NaN. No IEEE 754 floating-point operation provided by Java can distinguish between two NaN values of the same type with different bit patterns. Distinct values of NaN are only distinguishable by use of the {@code Float.floatToRawIntBits} method.

<p>In all other cases, let <i>s</i>, <i>e</i>, and <i>m</i> be three values that can be computed from the argument:

<blockquote><pre>{@code int s = ((bits >> 31) == 0) ? 1 : -1; int e = ((bits >> 23) & 0xff); int m = (e == 0) ? (bits & 0x7fffff) << 1 : (bits & 0x7fffff) | 0x800000; }</pre></blockquote>

Then the floating-point result equals the value of the mathematical expression <i>s</i>&middot;<i>m</i>&middot;2<sup><i>e</i>-150</sup>.

<p>Note that this method may not be able to return a {@code float} NaN with exactly same bit pattern as the {@code int} argument. IEEE 754 distinguishes between two kinds of NaNs, quiet NaNs and <i>signaling NaNs</i>. The differences between the two kinds of NaN are generally not visible in Java. Arithmetic operations on signaling NaNs turn them into quiet NaNs with a different, but often similar, bit pattern. However, on some processors merely copying a signaling NaN also performs that conversion. In particular, copying a signaling NaN to return it to the calling method may perform this conversion. So {@code intBitsToFloat} may not be able to return a {@code float} with a signaling NaN bit pattern. Consequently, for some {@code int} values, {@code floatToRawIntBits(intBitsToFloat(start))} may <i>not</i> equal {@code start}. Moreover, which particular bit patterns represent signaling NaNs is platform dependent; although all NaN bit patterns, quiet or signaling, must be in the NaN range identified above.

@param bits an integer. @return the {@code float} floating-point value with the same bit pattern.

class Float
static
float
intBitsToFloat
(
int bits
)

Meta