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 intThe default precision (number of digits = 3). -
Method Summary
Modifier and TypeMethodDescriptionstatic intget()Returns the current print precision (number of digits).static StringReturns 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 voidreset()Reset print precision to the default value (DefaultPrecision).static voidset(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 = 5the 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
-