Java Utililty Methods Decimal Format

List of utility methods to do Decimal Format

Description

The list of methods to do Decimal Format are organized into topic(s).

Method

Stringpadding(final double number)
padding
return FORMAT.format(number);
StringpadToMinWidth(double num, int minWidth)
pad To Min Width
NumberFormat nf = NumberFormat.getNumberInstance();
int intDigits = numDigits((int) num);
if (intDigits >= minWidth)
    nf.setMaximumFractionDigits(0);
else {
    boolean hasFracComponent = (int) num != num;
    if (hasFracComponent) {
        nf.setMaximumFractionDigits(minWidth - intDigits);
...
StringprettyPrintLatLon(double coord, boolean isCoordKindLat)
pretty Print Lat Lon
boolean neg = coord < 0.0;
String c;
if (isCoordKindLat) {
    c = (neg ? "S" : "N");
} else {
    c = (neg ? "W" : "E");
double tAbsCoord = Math.abs(coord);
...
voidprint(double[] y)
print
for (int i = 0; i < y.length; i++)
    System.out.print(_f.format(y[i]) + " ");
System.out.println();
StringprintAlpha(double a[])
print Alpha
DecimalFormat df = new DecimalFormat("0.0000");
StringBuilder sb = new StringBuilder();
sb.append(df.format(a[0]));
for (int i = 1; i < a.length; ++i) {
    sb.append("  ");
    sb.append(df.format(a[i]));
return sb.toString();
...
StringprintAngle(double angle)
Parses an angle value.
double degree = Math.toDegrees(angle);
return "d" + angleFormat.format(degree);
StringprintArray(String title, double[] vect)
print Array
String result = title + ": ";
result += arrayToString(vect);
result += "\n";
return result;
voidprintArrayP(double[][] p)
print Array P
for (int i = 0; i < p.length; i++) {
    for (int j = 0; j < p[i].length; j++) {
        System.out.print(df.format(p[i][j]));
        if (!(j + 1 == p[i].length)) {
            System.out.print(" , ");
    System.out.println("");
...
StringPrintWith1DecAnd000Sep(double Number)
Print With Dec And Sep
return F2b.format(Number);
doublerandomDouble(double minDouble, double maxDouble)
random Double
return minDouble == maxDouble ? minDouble
        : randomInt((int) getCorrectionValue(minDouble * 100000, 0),
                (int) getCorrectionValue(maxDouble * 100000, 0)) / 100000.0;