List of usage examples for java.math BigDecimal BigDecimal
public BigDecimal(long val)
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_DOWN); System.out.println(bg3);/*from ww w . j av a2 s. co 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_EVEN); System.out.println(bg3);//from ww w. ja va 2 s.co 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_UP); System.out.println(bg3);/*from w w w.jav a 2 s .c o m*/ }
From source file:Main.java
public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("123.145"); BigDecimal bg2 = new BigDecimal("110.01"); BigDecimal bg[] = bg1.divideAndRemainder(bg2); System.out.println("Quotient is " + bg[0]); System.out.println("Remainder is " + bg[1]); }
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_UNNECESSARY); System.out.println(bg3);/*from ww w . j a v a2 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_FLOOR); System.out.println(bg3);// ww w . ja v a2s . c o m }
From source file:Main.java
public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("123.23"); BigDecimal bg2 = new BigDecimal("12323"); BigDecimal bg3 = bg1.movePointRight(3); // 3 places right BigDecimal bg4 = bg2.movePointRight(-2);// 2 places left System.out.println(bg3);/*from www . j a va 2 s.co m*/ System.out.println(bg4); }
From source file:Main.java
public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("123.123456"); // set scale of bg1 to 6 in bg2 BigDecimal bg2 = bg1.setScale(6); String str = "The value of " + bg1 + " after changing the scale to 6 is " + bg2; System.out.println(str);/* ww w .java 2 s .com*/ }
From source file:Main.java
public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("16"); BigDecimal bg2 = new BigDecimal("3"); // divide bg1 with bg2 // 0 specifies BigDecimal.ROUND_UP BigDecimal bg3 = bg1.divide(bg2, BigDecimal.ROUND_UP); System.out.println(bg3);// ww w . j a v a2 s . co m }
From source file:Main.java
public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("16"); BigDecimal bg2 = new BigDecimal("3"); // divide bg1 with bg2 with 4 scale // 1 specifies BigDecimal.ROUND_DOWN BigDecimal bg3 = bg1.divide(bg2, 4, BigDecimal.ROUND_DOWN); System.out.println(bg3);/* w w w . j av a 2s . co m*/ }