/** creates a string from a real number, with specified accuracy (more iff it comes for free, ie integer-part); * switches to E notation if needed to fit within maxlen; can be padded left up too (not useful) * @param x number to use * @param maxlen maximum length for the numeric string, if possible (-1 to suppress) * @param prec number of digits accuracy desired (more kept for integers) * @param leftPadLen will add spaces at left if necessary to make string this long (-1 to suppress) [probably not usef] * @return such a string */ public static String makeRealString(double x, int maxlen, int prec, int leftPadLen) { return makeRealString(x, maxlen, prec, leftPadLen, 0.00000000001, true); } /** creates a string from a real number, with specified accuracy (more iff it comes for free, ie integer-part);
public String makeSizeString(long size) { long t = size; if (t==0) return "0"+suffixBytes; if (t<0) return "-"+makeSizeString(-t); long b = t%bytesPerMetricUnit; t = t/bytesPerMetricUnit; long kb = t%bytesPerMetricUnit; t = t/bytesPerMetricUnit; long mb = t%bytesPerMetricUnit; t = t/bytesPerMetricUnit; long gb = t; if (gb>0) return Strings.makeRealString(gb + (1.0*mb/bytesPerMetricUnit), maxLen, precision, 0) + suffixGiga; if (mb>0) return Strings.makeRealString(mb + (1.0*kb/bytesPerMetricUnit), maxLen, precision, 0) + suffixMega; if (kb>0) return Strings.makeRealString(kb + (1.0*b/bytesPerMetricUnit), maxLen, precision, 0) + suffixKilo; return b + suffixBytes; }
s = makeRealString(signif, -1, prec, -1) + "E"+log; } else { s = makeRealString(signif, -1, prec, -1) + "E"+log;
s = makeRealString(signif, -1, prec, -1) + "E"+log; } else { s = makeRealString(signif, -1, prec, -1) + "E"+log;