Example usage for java.math BigDecimal BigDecimal

List of usage examples for java.math BigDecimal BigDecimal

Introduction

In this page you can find the example usage for java.math BigDecimal BigDecimal.

Prototype

public BigDecimal(long val) 

Source Link

Document

Translates a long into a BigDecimal .

Usage

From source file:Main.java

public static void main(String[] args) {
    BigDecimal bg1 = new BigDecimal(new char[] { '1', '2' });
    System.out.println(bg1);//from   w  w  w .j  a v  a 2 s .c  o  m

}

From source file:Main.java

public static void main(String args[]) {
    BigDecimal bd = new BigDecimal(3.14159);
    bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP);

    System.out.println(bd);//  w  ww .  jav  a 2 s. com
}

From source file:Main.java

public static void main(String[] args) {
    BigDecimal bg1 = new BigDecimal(123.456);
    System.out.println(bg1);

}

From source file:Main.java

public static void main(String[] args) {
    BigDecimal bg1 = new BigDecimal(123456789L);
    System.out.println(bg1);

}

From source file:Main.java

public static void main(String[] args) {
    BigDecimal bg1 = new BigDecimal(123);
    System.out.println(bg1);

}

From source file:Main.java

public static void main(String[] args) {
    BigDecimal bg1 = new BigDecimal("123.456789");
    System.out.println(bg1);// w ww  . ja  v a2  s  .c  om

}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg = new BigDecimal("1E+4");

    System.out.println("Engineering string value of " + bg + " is " + bg.toEngineeringString());
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg = new BigDecimal("1234.123456");

    Float f = bg.floatValue();/*from ww w . j av  a 2  s.c  o m*/

    System.out.println(f);
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("12.1234");

    BigDecimal bg2 = bg1.negate();

    System.out.println(bg2);/*from   www  .  ja  v  a2s.  com*/
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("-123.126");

    BigDecimal bg2 = bg1.plus();/*from   ww  w  .  j a v a2  s . c  o  m*/

    System.out.println(bg2);
}