Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


The java.lang.Float.intBitsToFloat() method is used to return the 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. It includes the following important points:

  • If the argument is 0x7f800000, the result is positive infinity.
  • If the argument is 0xff800000, the result is negative infinity.
  • If the argument is any value in the range 0x7f800001 through 0x7fffffff or in the range 0xff800001 through 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 Float.floatToRawIntBits method.

Syntax

public static float intBitsToFloat(int bits)

Parameters

bits Specify an integer.

Return Value

Returns the float floating-point value with the same bit pattern.

Exception

NA.

Example:

In the below example, the java.lang.Float.intBitsToFloat() method is used to return the float value corresponding to a given bit representation.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {

    //creating int value
    int x = 5;
    int y = -5;

    //printing the float value corresponding to x
    System.out.print("intBitsToFloat value of x is: ");
    System.out.println(Float.intBitsToFloat(x)); 

    //printing the float value corresponding to y
    System.out.print("intBitsToFloat value of y is: "); 
    System.out.println(Float.intBitsToFloat(y));
  }
}

The output of the above code will be:

intBitsToFloat value of x is: 7.0E-45
intBitsToFloat value of y is: NaN

❮ Java.lang - Float