org.knowceans.util
Class ExpDouble

java.lang.Object
  extended by org.knowceans.util.ExpDouble

public class ExpDouble
extends java.lang.Object

ExpDouble represents a double-precision number by a mantissa, a decimal exponent and the number of digits in the mantissa, in order to allow formatting of the represented double.

Author:
gregor

Constructor Summary
ExpDouble(double x, int maxdigits)
          Creates an ExpDouble from a double, with the specified number of digits.
 
Method Summary
 java.lang.String debug()
           
static void main(java.lang.String[] args)
           
static int orderOfMagnitude(double x)
           
 boolean round(int ndigits)
          Round this instance to the number of significant digits
 double toDouble()
           
 double toDoubleUnsigned()
           
 java.lang.String toExpString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExpDouble

public ExpDouble(double x,
                 int maxdigits)
Creates an ExpDouble from a double, with the specified number of digits.

Parameters:
x -
maxdigits -
Method Detail

main

public static void main(java.lang.String[] args)

round

public boolean round(int ndigits)
Round this instance to the number of significant digits

Parameters:
digits -
Returns:
whether magnitude and digits had to be changed by rounding values >9.5 to 10

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
string representation of this object

toExpString

public java.lang.String toExpString()
Returns:
a string representation in exponential notation

debug

public java.lang.String debug()
Returns:
a debug string with the part of this ExpDouble

toDoubleUnsigned

public double toDoubleUnsigned()
Returns:
double representation of this object according to rounding.

toDouble

public double toDouble()
Returns:
double representation of this object according to rounding.

orderOfMagnitude

public static int orderOfMagnitude(double x)
Parameters:
x -
Returns:
order of magnitue of x, i.e., n : x in [ 10^n, 10^(n+1) )