org.knowceans.util
Class DoubleFormat
java.lang.Object
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
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 |
DoubleFormat
public DoubleFormat()
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: