Here you can find the source of toString(BigInteger[] vector)
Parameter | Description |
---|---|
vector | the BigInteger array |
public static String toString(BigInteger[] vector)
//package com.java2s; //License from project: LGPL import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.util.List; public class Main { public final static int DEC_PLACES = 4; /**// ww w . java2 s . c o m * List of states to string * * @param list * the list of states (byte arrays) * @return a string representing a list of states */ public static String toString(List<byte[]> list) { String result = "{"; for (byte[] vec : list) { result += toString(vec); } return result + "}"; } /** * Byte array to string * * @param vector * the byte array * @return textual representation of the byte array */ public static String toString(byte[] vector) { String result = "["; for (int i = 0; i < vector.length; i++) { result += vector[i]; } return result + "]"; } /** * Integer array to string * * @param vector * the integer array * @return textual representation of the integer array */ public static String toString(int[] vector) { if (vector.length == 0) return "[]"; String result = "[" + vector[0]; for (int i = 1; i < vector.length; i++) result += "," + vector[i]; return result + "]"; } /** * Long array to string * * @param vector * the long array * @return textual representation of the long array */ public static String toString(long[] vector) { if (vector.length == 0) return "[]"; String result = "[" + vector[0]; for (int i = 1; i < vector.length; i++) result += "," + vector[i]; return result + "]"; } /** * BigInteger array to string * * @param vector * the BigInteger array * @return textual representation of the BigInteger array */ public static String toString(BigInteger[] vector) { if (vector.length == 0) return "[]"; String result = "[" + vector[0]; for (int i = 1; i < vector.length; i++) result += "," + vector[i]; return result + "]"; } /** * Double array to string * * @param vector * the double array * @return textual representation of the double array */ public static String toString(double[] vector) { if (vector.length == 0) return "[]"; String result = "[" + vector[0]; for (int i = 1; i < vector.length; i++) result += "," + round(vector[i]); return result + "]"; } /** * String array to string * * @param vector * the String array * @return textual representation of the String array */ public static String toString(String[] vector) { if (vector.length == 0) return "[]"; String result = "[" + vector[0]; for (int i = 1; i < vector.length; i++) result += "," + vector[i]; return result + "]"; } /** * Boolean array to string * * @param vector * the Boolean array * @return textual representation of the Boolean array */ public static String toString(boolean[] vector) { if (vector.length == 0) return "[]"; String result = "[" + vector[0]; for (int i = 1; i < vector.length; i++) result += "," + vector[i]; return result + "]"; } /** * Integer matrix to string * * @param matrix * the matrix of integers * @return textual representation of the matrix of integers */ public static String toString(int[][] matrix) { StringBuffer result = new StringBuffer("{"); for (int i = 0; i < matrix.length; i++) result.append(toString(matrix[i]) + "\n"); return result.toString() + "}"; } /** * Double matrix to string * * @param matrix * the matrix of doubles * @return textual representation of the matrix of doubles */ public static String toString(double[][] matrix) { StringBuffer result = new StringBuffer("{"); for (int i = 0; i < matrix.length; i++) result.append(toString(matrix[i]) + "\n"); return result.toString() + "}"; } public static double round(double value, int decimalPlaces) { BigDecimal bd = new BigDecimal(value); bd = bd.setScale(decimalPlaces, RoundingMode.HALF_UP); return bd.doubleValue(); } public static double round(double value) { return round(value, DEC_PLACES); } }