Float floatToIntBits() method in Java with examples Last Updated : 26 Oct, 2018 Comments Improve Suggest changes Like Article Like Report The floatToIntBits() method in Float Class is a built-in function in java that returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout. Syntax: public static int floatToIntBits(float val) Parameter: The method accepts only one parameter val which specifies a floating-point number to be converted into integer bits. Return Values: The function returns the integer bits that represent the floating-point number. Below are the special cases: 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. Below programs illustrates the use of Float.floatToIntBits() method: Program 1: java // Java program to demonstrate // Float.floatToIntBits() method import java.lang.*; class Gfg1 { public static void main(String args[]) { float val = 1.5f; // function call int answer = Float.floatToIntBits(val); // print System.out.println(val + " in int bits: " + answer); } } Output: 1.5 in int bits: 1069547520 Program 2: Java // Java program to demonstrate // Float.floatToIntBits() method import java.lang.*; class Gfg1 { public static void main(String args[]) { float val = Float.POSITIVE_INFINITY; float val1 = Float.NEGATIVE_INFINITY; float val2 = Float.NaN; // function call int answer = Float.floatToIntBits(val); // print System.out.println(val + " in int bits: " + answer); // function call answer = Float.floatToIntBits(val1); // print System.out.println(val1 + " in int bits: " + answer); // function call answer = Float.floatToIntBits(val); // print System.out.println(val2 + " in int bits: " + answer); } } Output: Infinity in int bits: 2139095040 -Infinity in int bits: -8388608 NaN in int bits: 2139095040 Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Float.html#floatToIntBits(float) Comment More infoAdvertise with us Next Article Float floatToIntBits() method in Java with examples gopaldave Follow Improve Article Tags : Java java-basics Java-lang package Java-Functions Java-Float +1 More Practice Tags : Java Similar Reads Float floatToRawIntBits() method in Java with examples The floatToRawIntBits() method in Float Class is a built-in function in java that returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout, preserving Not-a-Number (NaN) values. Syntax: public static int floatToRawIntBits(floa 2 min read Float isInfinite() method in Java with examples The isInfinite() method in Float Class is a built in method in Java returns true if this Float value or the specifies float value is infinitely large in magnitude, false otherwise.Syntax: public boolean isInfinite() or public static boolean isInfinite(float val) Parameters: The function accepts a si 2 min read Float intValue() method in Java with examples The intValue() method in Float Class is a built in method in Java that returns the value specified by the calling object as int after type casting. Syntax: public int intValue() Parameters: The function accepts no parameter. Return Value: It return the value of FloatObject as int. Below programs ill 2 min read FloatBuffer get() methods in Java with Examples get() The get() method of java.nio.FloatBuffer Class is used to reads the float at the given buffer's current position, and then increments the position. Syntax : public abstract float get() Return Value: This method returns the float value at the buffer's current position. Throws: This method throw 5 min read Float floatValue() in Java with examples The floatValue() method in Float Class is a built-in function in java that returns the value specified by the calling object as float after type casting. Syntax: public float floatValue() Return Value: It returns the value of FloatObject as float. Below programs illustrate floatValue() method in Jav 2 min read Byte floatValue() method in Java with examples The floatValue() method of Byte class is a built in method in Java which is used to return the value of this Byte object as float. Syntax ByteObject.floatValue() Return Value: It return the value of ByteObject as float. Below is the implementation of floatValue() method in Java: Example 1: Java // J 2 min read Java floor() method with Examples The java.lang.Math.floor() returns the double value that is less than or equal to the argument and is equal to the nearest mathematical integer. Note: If the argument is Integer, then the result is Integer.If the argument is NaN or an infinity or positive zero or negative zero, then the result is th 2 min read Float compare() Method in Java with Examples The compare() method of Float Class is a built-in method in Java that compares the two specified float values. The sign of the integer value returned is the same as that of the integer that would be returned by the function call. Syntax: public static int compare(float f1, float f2)Parameters: The f 2 min read Number.floatValue() method in java with examples The floatValue() method is an inbuilt method in Java from the java.lang.Number class. This method is used when we want to extract the value of a Number object as a float data type. This may involve rounding or truncation, because this method returns the numeric value of the current object converted 2 min read FloatBuffer put() methods in Java with Examples put(float f) The put(float f) method of java.nio.FloatBuffer Class is used to write the given float into the newly created float buffer at the current position, and then increments the position. Syntax : public abstract FloatBuffer put(float f) Parameters: This method takes the float value f as a pa 6 min read Like