Class DoubleFormat
java.lang.Object
cnuphys.lund.DoubleFormat
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringdoubleFormat(double value, int numdec) Format a doublestatic StringdoubleFormat(double value, int numdec, boolean scinot) Format a doublestatic StringdoubleFormat(double value, int numdec, int minExponent) Format a double, switching from fixed to scientific notation.static voidmain program for testing.
-
Constructor Details
-
DoubleFormat
public DoubleFormat()
-
-
Method Details
-
doubleFormat
Format a double- Parameters:
value- the value to format.numdec- the number of digits right of the decimal.
-
doubleFormat
Format a double- Parameters:
value- the value to format.numdec- the number of digits right of the decimal.scinot- iftrue, use scientific notation.
-
doubleFormat
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 invalid input: '<'= -n it will use sci notation.minExponent- the minimum (absolute value) index for scientific notation.
-
main
main program for testing.- Parameters:
args- command line arguments (ignored.)
-