getExponent() Double in Java

getExponent(): This method is available in the Math class of Java.

Syntax:

int java.lang.Math.getExponent(double d)

This method takes one argument of type double as its parameter. This method returns the unbiased exponent used in the representation of a double. 

Special cases:

1. If the argument is NaN or infinite, then the result is Double.MAX_EXPONENT + 1.

2. If the argument is zero or subnormal, then the result is Double.MIN_EXPONENT -1.

Parameters: One parameter is required for this method.

d: a double value.

Returns: the unbiased exponent of the argument.

For Example:

Math.getExponent(18.2) = > It returns 4.

Approach

Java

public class GetExponentDouble {
    public static void main(String[] args) {

        double a = 18.2;
        System.out.println(Math.getExponent(a));

    }
}

Output:

4

No comments:

Post a Comment