Package com.pixelmed.utils

## Class FloatFormatter

- java.lang.Object
- - com.pixelmed.utils.FloatFormatter

-     public class FloatFormatter
      extends java.lang.Object

  Various static methods helpful for formatting floating point values.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static java.lang.String` | `stringValueForNaN` |
    `static java.lang.String` | `stringValueForNegativeInfinity` |
    `static java.lang.String` | `stringValueForPositiveInfinity` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static double[]` | `fromString​(java.lang.String s, char delimChar)` | Extract an arbitrary number of delimited numeric values from a string into an array of doubles.
    `static double[]` | `fromString​(java.lang.String s, int wanted, char delimChar)` | Extract a specified number of delimited numeric values from a string into an array of doubles.
    `static void` | `main​(java.lang.String[] arg)` |
    `static java.lang.String` | `toString​(double value)` | Given a double value, return a string representation without too many decimal places.
    `static java.lang.String` | `toString​(double value, java.util.Locale locale)` | Given a double value, return a string representation without too many decimal places.
    `static java.lang.String` | `toStringOfFixedMaximumLength​(double value, int maxLength, boolean allowNonNumbers)` | Given a double value, return a string representation that fits in a fixed length.
    `static java.lang.String` | `toStringOfFixedMaximumLength​(double value, int maxLength, boolean allowNonNumbers, java.util.Locale locale)` | Given a double value, return a string representation that fits in a fixed length.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### stringValueForNaN

          public static java.lang.String stringValueForNaN

    - #### stringValueForNegativeInfinity

          public static java.lang.String stringValueForNegativeInfinity

    - #### stringValueForPositiveInfinity

          public static java.lang.String stringValueForPositiveInfinity

  - ### Method Detail

    - #### toString

          public static java.lang.String toString​(double value)

      Given a double value, return a string representation without too many decimal places.

      Uses the default Locale for formatting, e.g., if the default is Locale.FRENCH, decimal point will be ",".

      Do NOT use this method for formatting strings that always need to have a period for a decimal point (such as DICOM DS values) but rather `toString(double,Locale)` and explictly specify the Locale to be Locale.US.

      Parameters:
        `value` - the value to format into a string
      Returns:
        the formatted string

    - #### toString

          public static java.lang.String toString​(double value,
                                                  java.util.Locale locale)

      Given a double value, return a string representation without too many decimal places.

      Parameters:
        `value` - the value to format into a string
        `locale` - locale to use when formatting (must be explicitly set to Locale.US when creating DICOM DS)
      Returns:
        the formatted string

    - #### toStringOfFixedMaximumLength

          public static java.lang.String toStringOfFixedMaximumLength​(double value,
                                                                      int maxLength,
                                                                      boolean allowNonNumbers)

      Given a double value, return a string representation that fits in a fixed length.

      Uses the default Locale for formatting, e.g., if the default is Locale.FRENCH, decimal point will be ",".

      Do NOT use this method for formatting strings that always need to have a period for a decimal point (such as DICOM DS values) but rather `toStringOfFixedMaximumLength(double,int,boolean,Locale)` and explictly specify the Locale to be Locale.US.

      Parameters:
        `value` - the value to format into a string
        `maxLength` - the maximum length of the string
        `allowNonNumbers` - whether to return NaN and infinity as string values (true), or as zero length string (false)
      Returns:
        the formatted string

    - #### toStringOfFixedMaximumLength

          public static java.lang.String toStringOfFixedMaximumLength​(double value,
                                                                      int maxLength,
                                                                      boolean allowNonNumbers,
                                                                      java.util.Locale locale)

      Given a double value, return a string representation that fits in a fixed length.

      Parameters:
        `value` - the value to format into a string
        `maxLength` - the maximum length of the string
        `allowNonNumbers` - whether to return NaN and infinity as string values (true), or as zero length string (false)
        `locale` - locale to use when formatting (must be explicitly set to Locale.US when creating DICOM DS)
      Returns:
        the formatted string

    - #### fromString

          public static final double[] fromString​(java.lang.String s,
                                                  int wanted,
                                                  char delimChar)

      Extract a specified number of delimited numeric values from a string into an array of doubles.

      Parameters:
        `s` - the string containing delimited double values
        `wanted` - the number of double values wanted
        `delimChar` - the delimiter character
      Returns:
        an array of doubles of the size wanted containing the values, else null

    - #### fromString

          public static final double[] fromString​(java.lang.String s,
                                                  char delimChar)

      Extract an arbitrary number of delimited numeric values from a string into an array of doubles.

      Parameters:
        `s` - the string containing delimited double values
        `delimChar` - the delimiter character
      Returns:
        an array of doubles of the size wanted containing the values, else null

    - #### main

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