org.knowceans.util
Class DoubleFormat

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

public class DoubleFormat
extends java.lang.Object

DoubleFormat formats double numbers into a specified digit format. The difference to NumberFormat and DecimalFormat is that this DigitFormat is based on a strategy to focus on a given number of nonzero digits, for which it rounds numbers if necessary. In addition, it is possible to format a number into a String that has a specified length, with a strategy to first obey the significant-digit rule and then try to either space-pad the string on the left or shorten the string by rounding, converting to mantissa-exponent format or indicating overflow or underflow. Although the class does not yield separator-aligned numbers, it yields a readable output.

Author:
heinrich

Constructor Summary
DoubleFormat()
           
 
Method Summary
static double format(double x, int ndigits)
          Format the number x with n significant digits.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DoubleFormat

public DoubleFormat()
Method Detail

main

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

format

public static double format(double x,
                            int ndigits)
Format the number x with n significant digits.

Parameters:
x -
ndigits -
Returns: