Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.util
Class DefaultDoubleFormatter

    java.lang.Object
      umontreal.iro.lecuyer.util.DefaultDoubleFormatter

All Implemented Interfaces:
  DoubleFormatter

    public class DefaultDoubleFormatter

extends Object
implements DoubleFormatter

Default formatter. Let x be a value to be formatted. Let d1 be the number of needed significant digits for | x|≤1, and d2 be the number of digits for | x| > 1. If x≥10d1, the formatter uses `PrintfFormat.f(double)` with 0 decimal digit of precision. If x < 10-d2, the formatter uses `PrintfFormat.e(double)` with d2 digits of precision. Otherwise, the formatter uses `PrintfFormat.g(double)` with d1 or d2 significant digits, depending if | x| is smaller than or equal to 1, or greater than 1.

Constructor Summary
`DefaultDoubleFormatter()` Constructs a formatter that uses 3 significant digits for all numbers.
`DefaultDoubleFormatter(int digitsSmall, int digitsLarge)` Constructs a formatter that uses `digitsSmall` significant digits for values smaller than 1, and `digitsLarge` significant digits for other values.

Method Summary
`String` | `format(double x)` Formats the double `x` as a string, and returns the resulting string.
`int` | `getDigitsLarge()` Returns the number of significant digits for values greater than or equal to 1.
`int` | `getDigitsSmall()` Returns the number of significant digits for values smaller than 1.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DefaultDoubleFormatter

    public DefaultDoubleFormatter()

  Constructs a formatter that uses 3 significant digits for all numbers.

### DefaultDoubleFormatter

    public DefaultDoubleFormatter(int digitsSmall,
                                  int digitsLarge)

  Constructs a formatter that uses `digitsSmall` significant digits for values smaller than 1, and `digitsLarge` significant digits for other values.

  Parameters:
    `digitsSmall` - the number of significant digits for values smaller than 1.
    `digitsLarge` - the number of significant digits for values greater than or equal to 1.

Method Detail

### getDigitsSmall

    public int getDigitsSmall()

  Returns the number of significant digits for values smaller than 1.

  Returns:
    the number of significant digits for values smaller than 1.

### getDigitsLarge

    public int getDigitsLarge()

  Returns the number of significant digits for values greater than or equal to 1.

  Returns:
    the number of significant digits for values greater than or equal to 1.

### format

    public String format(double x)

  Description copied from interface: `DoubleFormatter`
  Formats the double `x` as a string, and returns the resulting string.

  Specified by:
    `format` in interface `DoubleFormatter`
  Parameters:
    `x` - the value being formatted.
  Returns:
    the formatted value.

Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

To submit a bug or ask questions, send an e-mail to Richard Simard.