Here you can find the source of truncateDigits(double[][] input, int numberDigits)
public static String[][] truncateDigits(double[][] input, int numberDigits)
//package com.java2s; //License from project: LGPL public class Main { public static String[][] truncateDigits(double[][] input, int numberDigits) { String[][] result = new String[input.length][]; int indexDot = -1; String integerPart = null, decimalPart = null, dot = "."; String wholePart = null;/*from w ww. j a va2s . c o m*/ //int maxNumberDigit = 0; for (int i = 0; i < input.length; i++) { result[i] = new String[input[i].length]; for (int j = 0; j < input[i].length; j++) { System.out.println("input[" + i + "][" + j + "] = " + input[i][j]); wholePart = input[i][j] + ""; indexDot = (wholePart).indexOf(dot); if (indexDot >= 0) { integerPart = wholePart.substring(0, indexDot); try { decimalPart = wholePart.substring(indexDot + 1, indexDot + 1 + numberDigits); } catch (Exception e) { decimalPart = wholePart.substring(indexDot + 1, wholePart.length()); //decimalPart = wholePart.substring(indexDot + 1, ); } result[i][j] = integerPart + dot + decimalPart; } else { result[i][j] = input[i][j] + ""; } } } return result; } }