Class PrintPrecision

java.lang.Object
imagingbook.common.math.PrintPrecision

public abstract class PrintPrecision extends Object
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 Details

  • Method Details

    • reset

      public static void reset()
      Reset print precision to the default value (DefaultPrecision).
    • set

      public static void set(int nDigits)
      Set print precision to the specified number of digits. For example, with nDigits = 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

      public static int get()
      Returns the current print precision (number of digits).
      Returns:
      the current number of digits
    • getFormatStringFloat

      public static String getFormatStringFloat()
      Returns the floaing-point format string for the current print precision (to be used in String.format(String, Object...), for example "%.6f" if print precision is set to 6, or "%e" when precision ≤0.
      Returns:
      the format string