Java BigDecimal to String print(String tag, BigDecimal[][] a)

Here you can find the source of print(String tag, BigDecimal[][] a)

Description

print

License

Open Source License

Declaration



public static void print(String tag, BigDecimal[][] a) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigDecimal;

import java.text.DecimalFormat;
import java.util.Vector;

public class Main {
    private static DecimalFormat df = new DecimalFormat(" 0.00;-0");

    public static void print(Vector[] b) {
        for (int i = 0; i < b[0].size(); i++) { // cols
            for (int j = 0; j < b.length; j++) { // rows
                System.out.print(df.format(Double.parseDouble(b[j].get(i).toString())) + " ");
            }/*from   w  ww .ja  v  a2s.  c o m*/
            System.out.print("\n");
        }
        System.out.println();
    }

    public static void print(String tag, Vector[] b) {
        System.out.println(tag);
        print(b);
    }

    /***                         ***/

    // this method is for printing the A matrix with a label
    public static void print(String tag, BigDecimal[][] a) {
        System.out.println(tag);
        print(a);
    }

    public static void print(BigDecimal[][] a) {
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[0].length; j++)
                System.out.print(df.format(Double.parseDouble(a[j][i].toPlainString())) + " ");

            System.out.println();
        }
        System.out.println();
    }
}

Related

  1. bigDecimal2String(BigDecimal value)
  2. bigDecimal2String(BigDecimal value)
  3. bigDecimaltoString(BigDecimal bd)
  4. bigDecimalToString(BigDecimal number)