Float.floatToIntBits(): This method is available in java.lang.Float class of Java.
Syntax:
int java.lang.Float.floatToIntBits(float value)
This method takes one argument of type float as its parameter. This method returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout.
Note:
1. If the argument is positive infinity, the result is 0x7f800000.
2. If the argument is negative infinity, the result is 0xff800000.
3. If the argument is NaN, the result is 0x7fc00000.
Parameters: One parameter is required for this method.
value: a floating-point number.
Returns: the bits that represent the floating-point number.
For Example:
float value = (float) 16.5
Float.floatToIntBits(value) = > It returns 1099169792.
Approach
Java
public class FloatfloatToIntBits {public static void main(String[] args) {float value = (float) 16.5;System.out.println(Float.floatToIntBits(value));}}
Output:
1099169792
No comments:
Post a Comment