jnt.Bench.Formatter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scimark Show documentation
Show all versions of scimark Show documentation
SciMark 2.0 is a Java benchmark for scientific and numerical
computing. It measures several computational kernels and reports a composite
score in approximate Mflops (Millions of floating point operations per
second).
The newest version!
/*****************************************************************************
jnt.Bench.Formatter
*****************************************************************************/
package jnt.Bench;
/**
An EXTREMELY Lame & Minimal Number formatter.
Only what is essential for the Benchmarker...
I'll evolve it if necessary.
Need to hack in some robustness !!!!
@author Bruce R. Miller ([email protected])
@author Contribution of the National Institute of Standards and Technology,
@author not subject to copyright.
*/
public class Formatter {
static final int MAXDEC=15;
/** Create a string of `padding' consisting of n copies of c.*/
public static String pad(char c, int n){
if (n <= 0) return "";
char s[]=new char[n];
for(int i=0; i MAXDEC) return Double.toString(num); // punt!
double shifted = num*Math.pow(10.0,ndecs);
if (Math.abs(shifted) > Long.MAX_VALUE) return Double.toString(num); // punt!
String s = Long.toString((long) shifted);
StringBuffer sb = new StringBuffer();
sb.append(pad('0',ndecs-s.length()+1)); // need Padding on left.
sb.append(s);
if (ndecs > 0)
sb.insert(sb.length()-ndecs,'.');
else
sb.append(pad('0',-ndecs));
return sb.toString();
} catch(Exception e) {
return Double.toString(num); }} // punt!
/** Format an array of numbers, returning an array of strings.*/
public static String[] format(double nums[], int ndecs){
String vals[]=new String[nums.length];
for(int i=0; il0) l0=ll;
if((ll=column[i].length())>l1) l1=ll; }
for(int i=0; i