Package org.orekit.utils.formatting
Class FastDecimalFormatter
java.lang.Object
org.orekit.utils.formatting.FastDoubleFormatter
org.orekit.utils.formatting.FastDecimalFormatter
Formatter for double numbers with low overhead.
This class is intended to be used when formatting large amounts of data with fixed formats like, for example, large ephemeris or measurement files.
Building the formatter is done once, and the formatter
FastDoubleFormatter.appendTo(Appendable, double) or FastDoubleFormatter.toString(double) methods can
be called hundreds of thousands of times, without incurring the overhead that
would occur with String.format(). Some tests showed this formatter is
about 5 times faster than String.format() with
%{width}.{%precision}f format.
Instances of this class are immutable
- Since:
- 13.0.3
- Author:
- Luc Maisonobe
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendRegularValueTo(Appendable appendable, double value) Append one formatted value to anAppendable.intGet the precision.Methods inherited from class org.orekit.utils.formatting.FastDoubleFormatter
appendTo, getWidth, toString
-
Constructor Details
-
FastDecimalFormatter
public FastDecimalFormatter(int width, int precision) Simple constructor.This constructor is equivalent to
Formatterfloat format%{width}.{precision}f- Parameters:
width- number of characters to outputprecision- number of decimal precision
-
-
Method Details
-
getPrecision
public int getPrecision()Get the precision.- Returns:
- precision
-
appendRegularValueTo
Append one formatted value to anAppendable.- Specified by:
appendRegularValueToin classFastDoubleFormatter- Parameters:
appendable- to append value tovalue- value to format- Throws:
IOException- if an I/O error occurs
-