Javatpoint Logo
Javatpoint Logo

Java Float floatToIntBits() method

The floatToIntBits() method of Float class returns the specified floating-point value according to the IEEE 754 floating-point 'single format' bit layout.

Syntax:

Parameters:

A float type parameter (value) is passed where value is a floating-point number.

Return Value:

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

  • If the argument is positive infinity, it will return 0x7f800000.
  • If the argument is negative infinity, it will return 0xff800000.
  • If the argument is NaN, it will return 0x7fc00000.

Example 1

Test it Now

Output:

Equivalent integer bits = 1116169830

Example 2

Test it Now

Output:

67.5 value in int Bits = 1116143616
Infinity value in int Bits = 2139095040
NaN value in int Bits = 2143289344
-Infinity value in int Bits = -8388608

Example 3

Test it Now

Output:

Error:(12, 23) java: cannot find symbol
  symbol:   method floatToIntBits(java.lang.Float)
  location: variable obj1 of type com.interf.Float_floatToIntBitsMethod_Example2

The floatToIntBits() is a static method of Float class so, it will always be called with Float class name otherwise, it will give an error like above.


Next TopicJava Float





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA