getExponent(): This method is available in the Math class of Java.
Syntax:
int java.lang.Math.getExponent(float f)
This method takes one argument of type float as its parameter. This method returns the unbiased exponent used in the representation of a float.
Special cases:
1. If the argument is NaN or infinite, then the result is Float.MAX_EXPONENT + 1.
2. If the argument is zero or sub normal, then the result is Float.MIN_EXPONENT -1.
Parameters: One parameter is required for this method.
f: a float value
Returns: the unbiased exponent of the argument.
For Example:
Math.getExponent(8.5) = > It returns 3.
Approach
Java
public class GetExponentFloat {public static void main(String[] args) {float x = (float) 8.5;System.out.println(Math.getExponent(x));}}
Output:
3
No comments:
Post a Comment