java.lang.Object
imagingbook.common.math.PrintPrecision
This class holds settings to control the precision when printing floating-point numbers, used in particular by
various
toString()
methods for vectors and matrices defined in class Matrix
(mainly for debugging).-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The default precision (number of digits = 3). -
Method Summary
Modifier and TypeMethodDescriptionstatic int
get()
Returns the current print precision (number of digits).static String
Returns the floaing-point format string for the current print precision (to be used inString.format(String, Object...)
, for example"%.6f"
if print precision is set to 6, or"%e"
when precision ≤0.static void
reset()
Reset print precision to the default value (DefaultPrecision
).static void
set
(int nDigits) Set print precision to the specified number of digits.
-
Field Details
-
DefaultPrecision
The default precision (number of digits = 3).- See Also:
-
-
Method Details
-
reset
Reset print precision to the default value (DefaultPrecision
). -
set
Set print precision to the specified number of digits. For example, withnDigits = 5
the resulting element format string is"%.5f"
. If a value ≤0 is specified, the scientific float format string"%e"
is used.- Parameters:
nDigits
- the number of digits to be used
-
get
Returns the current print precision (number of digits).- Returns:
- the current number of digits
-
getFormatStringFloat
Returns the floaing-point format string for the current print precision (to be used inString.format(String, Object...)
, for example"%.6f"
if print precision is set to 6, or"%e"
when precision ≤0.- Returns:
- the format string
-