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 bg = new BigDecimal("1234");

    // assign the converted value of bg to d
    Double d = bg.doubleValue();/*from  ww w .j  a  v a  2s . com*/

    System.out.println(d);
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("9.8");
    BigDecimal bg2 = new BigDecimal("3");

    BigDecimal bg3 = bg1.divideToIntegralValue(bg2);

    System.out.println(bg3);//from   w w w  .  j  a  v a2  s . c o  m
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("123");
    BigDecimal bg2 = new BigDecimal("456");

    BigDecimal bg3 = bg1.min(bg2);

    System.out.println(bg3);//from   w w w . j av a2  s.  c om
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("1.230");
    BigDecimal bg2 = new BigDecimal("4.560");

    BigDecimal bg3 = bg1.multiply(bg2);

    System.out.println(bg3);//  ww w  .  j a  v a  2 s.  co m
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("45");
    BigDecimal bg2 = new BigDecimal("5");

    BigDecimal bg3 = bg1.divide(bg2); // divide bg1 with bg2

    System.out.println(bg3);/* www.jav  a  2s.c  om*/
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("1.23");

    // apply pow method on bg1
    BigDecimal bg2 = bg1.pow(3);/* w w  w . j a  v a 2 s . c  o m*/

    System.out.println(bg2);
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("40");

    BigDecimal bg2 = new BigDecimal("3");

    BigDecimal bg3 = bg1.divide(bg2, BigDecimal.ROUND_CEILING);

    System.out.println(bg3);/* www .j a  va  2s .c o m*/
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("40");

    BigDecimal bg2 = new BigDecimal("3");

    BigDecimal bg3 = bg1.divide(bg2, BigDecimal.ROUND_HALF_DOWN);

    System.out.println(bg3);//w  w w.  j  a  v a 2  s. c  o  m
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("40");

    BigDecimal bg2 = new BigDecimal("3");

    BigDecimal bg3 = bg1.divide(bg2, BigDecimal.ROUND_UP);

    System.out.println(bg3);//ww  w.  ja va 2 s .  co m
}

From source file:Main.java

public static void main(String[] args) {

    BigDecimal bg1 = new BigDecimal("123");
    BigDecimal bg2 = new BigDecimal("456");

    // assign the max value of bg1, bg2 to bg3
    BigDecimal bg3 = bg1.max(bg2);

    System.out.println(bg3);//from  w  w  w.jav a 2s.co  m
}