SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.number
Class ScientificNotation

java.lang.Object
  extended by java.lang.Number
      extended by com.numericalmethod.suanshu.number.ScientificNotation
All Implemented Interfaces:
java.io.Serializable

public class ScientificNotation
extends java.lang.Number

Scientific notation expresses a number in this form

x = a * 10b

a is called 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. In this implementation, however, we will express it as x = 0 * 100

See Also:
Wikipedia: Scientific notation, Serialized Form

Field Summary
 int exponent
          the exponent
 java.math.BigDecimal significand
          the significand or mantissa
 
Constructor Summary
ScientificNotation(java.math.BigDecimal x)
          Construct a ScientificNotation from a BigDecimal.
ScientificNotation(java.math.BigDecimal significand, int exponent)
          Construct a ScientificNotation for x = a * 10b.
ScientificNotation(java.math.BigInteger x)
          Construct a ScientificNotation from a BigInteger.
ScientificNotation(double x)
          Construct a ScientificNotation from a double.
ScientificNotation(double significand, int exponent)
          Construct a ScientificNotation for x = a * 10b.
ScientificNotation(long x)
          Construct a ScientificNotation from a long.
 
Method Summary
 double doubleValue()
           
 float floatValue()
           
 int intValue()
           
 long longValue()
           
 java.math.BigDecimal value()
          Get the value of the specified number as a BigDecimal.
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

significand

public final java.math.BigDecimal significand
the significand or mantissa


exponent

public final int exponent
the exponent

Constructor Detail

ScientificNotation

public ScientificNotation(double significand,
                          int exponent)
Construct a ScientificNotation for x = a * 10b.

Parameters:
significand - the significand
exponent - the exponent

ScientificNotation

public ScientificNotation(java.math.BigDecimal significand,
                          int exponent)
Construct a ScientificNotation for x = a * 10b.

Parameters:
significand - the significand
exponent - the exponent

ScientificNotation

public ScientificNotation(java.math.BigDecimal x)
Construct a ScientificNotation from a BigDecimal.

Parameters:
x - a BigDecimal number

ScientificNotation

public ScientificNotation(java.math.BigInteger x)
Construct a ScientificNotation from a BigInteger.

Parameters:
x - a BigInteger integer

ScientificNotation

public ScientificNotation(long x)
Construct a ScientificNotation from a long.

Parameters:
x - a long integer

ScientificNotation

public ScientificNotation(double x)
Construct a ScientificNotation from a double.

Parameters:
x - a double number
Method Detail

intValue

public int intValue()
Specified by:
intValue in class java.lang.Number

longValue

public long longValue()
Specified by:
longValue in class java.lang.Number

floatValue

public float floatValue()
Specified by:
floatValue in class java.lang.Number

doubleValue

public double doubleValue()
Specified by:
doubleValue in class java.lang.Number

value

public java.math.BigDecimal value()
Get the value of the specified number as a BigDecimal. There is no rounding.

Returns:
the numeric value represented by this object after conversion to type BigDecimal.

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.