List of usage examples for java.math BigDecimal BigDecimal
public BigDecimal(long val, MathContext mc)
From source file:Main.java
public static void main(String[] args) { BigDecimal bg1 = new BigDecimal(new BigInteger("40"), 2); }
From source file:Main.java
public static void main(String[] args) { MathContext mc = new MathContext(3); BigDecimal bg1 = new BigDecimal(123.456789, mc); System.out.println(bg1);/*from www . j a v a 2s.c om*/ }
From source file:Main.java
public static void main(String[] args) { MathContext mc = new MathContext(3); BigDecimal bg1 = new BigDecimal(123456789L, mc); System.out.println(bg1);//from w ww.ja va 2s . c om }
From source file:Main.java
public static void main(String[] args) { MathContext mc = new MathContext(3); BigDecimal bg1 = new BigDecimal(123, mc); System.out.println(bg1);/* w w w.ja va 2 s .c om*/ }
From source file:Main.java
public static void main(String[] args) { MathContext mc = new MathContext(3); BigDecimal bg1 = new BigDecimal("123", mc); System.out.println(bg1);// w w w. j av a 2s. c o m }
From source file:Main.java
public static void main(String[] args) { MathContext mc = new MathContext(3); // 3 precision BigDecimal bg = new BigDecimal("1234E4", mc); System.out.println(bg.toString()); }
From source file:Main.java
public static void main(String[] args) { MathContext mc = new MathContext(3); // 3 precision BigDecimal bg = new BigDecimal("1234E+4", mc); System.out.println("Plain string value of " + bg + " is " + bg.toPlainString()); }
From source file:Main.java
public static void main(String[] args) { MathContext mc = new MathContext(3); BigDecimal bg1 = new BigDecimal(new BigInteger("40"), mc); }
From source file:Main.java
public static void main(String[] args) { MathContext mc = new MathContext(3); char[] ch = new char[] { '1', '2', '3', '4', '5', '6', '7' }; BigDecimal bg1 = new BigDecimal(ch, mc); System.out.println(bg1);//from w w w.j av a 2 s .c om }
From source file:Main.java
public static BigDecimal cuberoot(BigDecimal b) { // Specify a math context with 40 digits of precision. MathContext mc = new MathContext(40); BigDecimal x = new BigDecimal("1", mc); // Search for the cube root via the Newton-Raphson loop. Output each // successive iteration's value. for (int i = 0; i < ITER; i++) { x = x.subtract(/* www . j a v a2s. c om*/ x.pow(3, mc).subtract(b, mc).divide(new BigDecimal("3", mc).multiply(x.pow(2, mc), mc), mc), mc); } return x; }