Float.floatToRawIntBits(): This method is available in java.lang.Float class of Java.
Syntax:
int java.lang.Float.floatToRawIntBits(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, preserving Not-a-Number (NaN) values.
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 the integer representing the actual NaN value.
Parameters: One parameter is required for this method.
value: a floating-point number.
Returns: the bits that represent the floating-point number.
Approach
Java
public class FloatfloatToRawIntBits {public static void main(String[] args) {float value = (float) 15.6;System.out.println(Float.floatToRawIntBits(value));}}
Output:
1098488218
No comments:
Post a Comment