Here you can find the source of arrayStringR(double[] data)
public static String arrayStringR(double[] data)
//package com.java2s; //License from project: Open Source License public class Main { public static String arrayStringR(double[] data) { if (data == null) return null; StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.length; i++) { buf.append(round(data[i]) + " "); }/*from ww w. j a v a2 s . c om*/ return buf.toString(); } public static String arrayStringR(double[][] data) { if (data == null) return null; StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[i].length; j++) { buf.append(round(data[i][j], 2) + " "); } buf.append("\n"); } return buf.toString(); } public static String arrayStringR(float[][] data) { if (data == null) return null; StringBuffer buf = new StringBuffer(); for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[i].length; j++) { buf.append(round(data[i][j], 2) + " "); } buf.append("\n"); } return buf.toString(); } /** Rounds the number to 4 significant digits */ public static double round(double d) { if (d == 0.0) return d; int digits = (int) (Math.log(d) / Math.log(10)); return round(d, 3 - digits); } /** Rounds the number to n decimal places */ public static double round(double d, int n) { double shift = Math.pow(10, n); return ((double) ((long) (d * shift + 0.5))) / shift; } }