Home » Java programming language

Java Float class intBitsToFloat() method with example

Float class intBitsToFloat() method: Here, we are going to learn about the intBitsToFloat() method of Float class with its syntax and example.
Submitted by Preeti Jain, on October 04, 2019

Float class intBitsToFloat() method

  • intBitsToFloat() method is available in java.lang package.
  • intBitsToFloat() method follows IEEE 754 floating-point standards and according to standards, it returns the float value corresponding to a given argument that denotes integer bits representation.
  • intBitsToFloat() method is a static method, it is accessible with the class name too and if we try to access the method with the class object then also we will not get an error.
  • intBitsToFloat() method does not throw an exception at the time of converting bits representations to float value.


    public static float intBitsToFloat(int bits_rep);


  • int bits_rep – represents the integer value in bits.

Return value:

The return type of this method is float, it returns the float value that represent the given argument in integer bits.

  • If we pass "0x7f800000", it returns the value "positive infinity".
  • If we pass "0xff800000", it returns the value "negative infinity".
  • If value lies in between "0x7f800001" and "0x7fffffff" or the value lies in between "0xff800001" and "0xffffffff".


// Java program to demonstrate the example 
// of intBitsToFloat (int bits_rep)
// method of Float class

public class IntBitsToFloatOfFloatClass {
    public static void main(String[] args) {
        // Variables initialization
        int value1 = 20;
        int value2 = 0x7f800000;
        int value3 = 0xff800000;

        // Display value1,value2,value3 values
        System.out.println("value1: " + value1);
        System.out.println("value2: " + value2);
        System.out.println("value3: " + value3);

        // It returns the float value denoted by the given 
        // bit representation by calling Float.intBitsToFloat(value1)
        float result1 = Float.intBitsToFloat(value1);

        // It returns the float value denoted by the given 
        // bit representation by calling Float.intBitsToFloat(value2)
        float result2 = Float.intBitsToFloat(value2);

        // It returns the float value denoted by the given 
        // bit representation by calling Float.intBitsToFloat(value3)
        float result3 = Float.intBitsToFloat(value3);

        // Display result1,result2, result3 values
        System.out.println("Float.intBitsToFloat(value1): " + result1);
        System.out.println("Float.intBitsToFloat(value2): " + result2);
        System.out.println("Float.intBitsToFloat(value3): " + result3);


value1: 20
value2: 2139095040
value3: -8388608
Float.intBitsToFloat(value1): 2.8E-44
Float.intBitsToFloat(value2): Infinity
Float.intBitsToFloat(value3): -Infinity


Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.