Java Math getExponent() Method
Example
Get the exponent of different floating point numbers:
System.out.println(Math.getExponent(1));
System.out.println(Math.getExponent(2));
System.out.println(Math.getExponent(-8));
System.out.println(Math.getExponent(10));
System.out.println(Math.getExponent(0.5));
System.out.println(Math.getExponent(-0.33));
Definition and Usage
The getExponent()
method returns the unbiased exponent of Java's internal representation of a floating point number.
Java represents every floating point number internally in the form m·2x. The getExponent()
method returns the value of x for any floating point number. The term unbiased refers to the fact that the exponent can only be represented internally as a positive number, so there is a positive bias to the exponent. When you subtract the bias from the exponent you get the unbiased (true) value of the exponent.
Syntax
One of the following:
public static int getExponent(double number)
public static int getExponent(float number)
Parameter Values
Parameter | Description |
---|---|
number | Required. A floating point number from which to get the exponent. |
Technical Details
Returns: | An int value representing the unbiased exponent of Java's internal representation of a floating point number. |
---|---|
Java version: | 1.6+ |
❮ Math Methods