java.lang.Float floatToIntBits(float value)


The floatToIntBits(float value) method of Float class is use to get the representation of the specified floating-point value according to the IEEE 754 floating-point “single format” bit layout.

Method Syntax

public static int floatToIntBits(float value)

Method Argument

Data Type Parameter Description
float value a floating-point number.

Method Returns

The floatToIntBits(float value)  method of Float class returns the bits that represent the floating-point number.


Java 1.0


There are some rules governing the floatToIntBits method and here as follows:

  • If the argument is positive infinity, the result is 0x7f800000.
  • If the argument is negative infinity, the result is 0xff800000.
  • If the argument is NaN, the result is 0x7fc00000
  • In all cases, the result is an integer, when given to the intBitsToFloat(int) method, will produce a floating-point value the same as the argument to floatToIntBits  but of course there is an exception when the value is Nan and will then defaulted to one universal value which is Nan.

Java Float floatToIntBits(float value) Example

Below is a simple java example on the usage of floatToIntBits(float value) method of Float class.


import java.util.Scanner;

import static java.lang.System.*;

 * This example source code demonstrates the use of 
 * floatToIntBits(float value) method of Float class.

public class FloatToIntBitsExample {

	public static void main(String[] args) {

		// Ask user input for a number
		System.out.print("Enter First Number:");
		// declare the scanner object
		Scanner scan = new Scanner(;
		// use scanner to get value from user console
		Float value = scan.nextFloat();
		// close the scanner object

		 * code block to print the result of floatToIntBits method

Basically on the above example, we just ask for user input on the console and then we use the scanner object to get the float input. After that we assign the value to an Float wrapper class and we then get the integer bits equivalent using the floatToIntBits(float value) method of Float class.

Sample Output

Below is the sample output when you run the above example.

Float floatToIntBits() Sample Output