Class DoubleFormat

java.lang.Object
cnuphys.splot.plot.DoubleFormat

public class DoubleFormat extends Object
  • Constructor Details

    • DoubleFormat

      public DoubleFormat()
  • Method Details

    • doubleFormat

      public static String doubleFormat(double value, int numdec)
      Format a double
      Parameters:
      value - the value to format.
      numdec - the number of digits right of the decimal.
    • doubleFormat

      public static String doubleFormat(double value, int numdec, boolean scinot)
      Format a double
      Parameters:
      value - the value to format.
      numdec - the number of digits right of the decimal.
      scinot - if true, use scientific notation.
    • doubleFormat

      public static String doubleFormat(double value, int numdec, int minExponent)
      Format a double, switching from fixed to scientific notation.

      Example:
      numdec = 6
      minExponent = 2
      value starts at 12345.67 and keep dividing by 10 gives
      1.234567E4
      1.234567E3
      1.234567E2
      12.345670
      1.234567
      0.123457
      1.234567E-2
      1.234567E-3
      1.234567E-4
      1.234567E-5
      1.234567E-6
      1.234567E-7

      Parameters:
      value - the value to format.
      numdec - the number of digits right of the decimal. If the exponenent is >= n or <= -n it will use sci notation.
      minExponent - the minimum (absolute value) index for scientific notation.
    • main

      public static void main(String[] args)
      main program for testing.
      Parameters:
      args - command line arguments (ignored.)