Float.intBitsToFloat(): This method is available in java.lang.Float class of Java.
Syntax:
float java.lang.Float.intBitsToFloat(int bits)
This method takes one argument of type int as its parameter. This method returns 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.
Note:
1. If the argument is 0x7f800000, the result is positive infinity.
2. If the argument is 0xff800000, the result is negative infinity.
3. If the argument is any value in the range 0x7f800001 through 0x7fffffff or in the range 0xff800001 through 0xffffffff, the result is a NaN.
Parameters: One parameter is required for this method.
bits: an integer.
Returns: the float floating-point value with the same bit pattern.
For Example:
int bits = 18818
Float.intBitsToFloat(bits) = > It returns 2.637E-41
Approach
Java
public class FloatintBitsToFloat {public static void main(String[] args) {int bits = 18818;System.out.println(Float.intBitsToFloat(bits));}}
Output:
2.637E-41
No comments:
Post a Comment