Package dev.nm.number
Class ScientificNotation
- java.lang.Object
-
- java.lang.Number
-
- dev.nm.number.ScientificNotation
-
- All Implemented Interfaces:
Serializable
public class ScientificNotation extends Number
Scientific notation expresses a number in this formx = a * 10b
a is called the significand or mantissa, and 1 ≤ |a| < 10. b is called the exponent and is an integer. Strictly speaking, 0 cannot be represented in this notation. This implementation, however, expresses it as 0 = 0 * 100.- See Also:
- Wikipedia: Scientific notation, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ScientificNotation(double x)Construct the scientific notation of adouble.ScientificNotation(double significand, int exponent)Construct the scientific notation of a number in this form: x = a * 10b.ScientificNotation(long x)Construct the scientific notation of along.ScientificNotation(BigDecimal x)Construct the scientific notation of a number.ScientificNotation(BigDecimal significand, int exponent)Construct the scientific notation of a number in this form: x = a * 10b.ScientificNotation(BigInteger x)Construct the scientific notation of an integer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BigDecimalbigDecimalValue()Convert the number toBigDecimal.doubledoubleValue()intexponent()Get the exponent.floatfloatValue()intintValue()longlongValue()BigDecimalsignificand()Get the significand.-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Constructor Detail
-
ScientificNotation
public ScientificNotation(double significand, int exponent)Construct the scientific notation of a number in this form: x = a * 10b.- Parameters:
significand- the significandexponent- the exponent
-
ScientificNotation
public ScientificNotation(BigDecimal significand, int exponent)
Construct the scientific notation of a number in this form: x = a * 10b.- Parameters:
significand- the significandexponent- the exponent
-
ScientificNotation
public ScientificNotation(BigDecimal x)
Construct the scientific notation of a number.- Parameters:
x- a number
-
ScientificNotation
public ScientificNotation(BigInteger x)
Construct the scientific notation of an integer.- Parameters:
x- an integer
-
ScientificNotation
public ScientificNotation(long x)
Construct the scientific notation of along.- Parameters:
x- alonginteger
-
ScientificNotation
public ScientificNotation(double x)
Construct the scientific notation of adouble.- Parameters:
x- adoublenumber
-
-
Method Detail
-
significand
public BigDecimal significand()
Get the significand.- Returns:
- the significand
-
exponent
public int exponent()
Get the exponent.- Returns:
- the exponent
-
bigDecimalValue
public BigDecimal bigDecimalValue()
Convert the number toBigDecimal. There is no rounding.- Returns:
- the
BigDecimalrepresentation of the number
-
floatValue
public float floatValue()
- Specified by:
floatValuein classNumber
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein classNumber
-
-