Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

getExponent()

Example

Retrieve the exponents of various 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 retrieves the unbiased exponent of a floating-point number as represented internally in Java.

Java internally represents each floating-point number as m·2^x. The getExponent() method provides the value of x for any floating-point number. The term “unbiased” indicates that the exponent is internally stored only as a positive number, introducing a positive bias. Subtracting this bias from the exponent yields 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

Needed: A floating-point number for which to retrieve the exponent.

Technical Details

Returns

An integer value that signifies the impartial exponent in Java’s internal depiction of a floating-point number.

Java Version

1.6+