Class OrdinateFormat


  • public class OrdinateFormat
    extends Object
    Formats numeric values for ordinates in a consistent, accurate way.

    The format has the following characteristics:

    • It is consistent in all locales (in particular, the decimal separator is always a period)
    • Scientific notation is never output, even for very large numbers. This means that it is possible that output can contain a large number of digits.
    • The maximum number of decimal places reflects the available precision
    • NaN values are represented as "NaN"
    • Inf values are represented as "Inf" or "-Inf"
    Author:
    mdavis
    • Field Detail

      • MAX_FRACTION_DIGITS

        public static final int MAX_FRACTION_DIGITS
        The maximum number of fraction digits to support output of reasonable ordinate values. The default is chosen to allow representing the smallest possible IEEE-754 double-precision value, although this is not expected to occur (and is not supported by other areas of the JTS code).
        See Also:
        Constant Field Values
      • DEFAULT

        public static OrdinateFormat DEFAULT
        The default formatter using the maximum number of digits in the fraction portion of a number.
    • Constructor Detail

      • OrdinateFormat

        public OrdinateFormat()
        Creates an OrdinateFormat using the default maximum number of fraction digits.
      • OrdinateFormat

        public OrdinateFormat​(int maximumFractionDigits)
        Creates an OrdinateFormat using the given maximum number of fraction digits.
        Parameters:
        maximumFractionDigits - the maximum number of fraction digits to output
    • Method Detail

      • create

        public static OrdinateFormat create​(int maximumFractionDigits)
        Creates a new formatter with the given maximum number of digits in the fraction portion of a number.
        Parameters:
        maximumFractionDigits - the maximum number of fraction digits to output
        Returns:
        a formatter
      • format

        public String format​(double ord)
        Returns a string representation of the given ordinate numeric value.
        Parameters:
        ord - the ordinate value
        Returns:
        the formatted number string