Example usage for java.math BigDecimal doubleValue

List of usage examples for java.math BigDecimal doubleValue

Introduction

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

Prototype

@Override
public double doubleValue() 

Source Link

Document

Converts this BigDecimal to a double .

Usage

From source file:Main.java

public static void main(String args[]) {
    double r = 3.1234567;
    int decimalPlace = 2;
    BigDecimal bd = new BigDecimal(r);
    bd = bd.setScale(decimalPlace, BigDecimal.ROUND_UP);
    r = bd.doubleValue();
    System.out.println(r);/*from   w  ww. j  a  va2 s .com*/
}

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();

    System.out.println(d);//w  w w .  j a va  2 s.  co  m
}

From source file:Main.java

public static void main(String[] args) {
    double operation = 890.0 / 1440.0;
    BigDecimal big = new BigDecimal(operation);
    big = big.setScale(4, RoundingMode.HALF_UP);
    double d2 = big.doubleValue();
    System.out.println(String.format("operation : %s", operation));
    System.out.println(String.format("scaled : %s", d2));
}

From source file:Main.java

public static void main(String[] args) {
    BigDecimal payment = new BigDecimal("12345.67");
    NumberFormat n = NumberFormat.getCurrencyInstance(Locale.US);
    double doublePayment = payment.doubleValue();
    String s = n.format(doublePayment);
    System.out.println(s);/*from  ww  w .  j  a va  2  s. co  m*/
}

From source file:edu.macalester.tagrelatedness.KendallsCorrelation.java

public static void main(String args[]) {
    long tiedx = new BigInteger("1853724906736").longValue();
    long tiedy = new BigInteger("5328254589").longValue();
    long numpairs = new BigInteger("4094164093575").longValue();
    BigSquareRoot sqrt = new BigSquareRoot();
    BigInteger first = new BigInteger("" + (numpairs - tiedx));
    BigInteger second = new BigInteger("" + (numpairs - tiedy));
    BigDecimal result = sqrt.get(first.multiply(second));
    System.out.println(result.doubleValue());

}

From source file:Main.java

public static String toReal(BigDecimal value) {
    return toReal(value.doubleValue());
}

From source file:Main.java

public static BigDecimal atan(BigDecimal val) {
    return BigDecimal.valueOf(Math.atan(val.doubleValue()));
}

From source file:Main.java

public static BigDecimal acos(BigDecimal val) {
    return BigDecimal.valueOf(Math.acos(val.doubleValue()));
}

From source file:Main.java

public static BigDecimal asin(BigDecimal val) {
    return BigDecimal.valueOf(Math.asin(val.doubleValue()));
}

From source file:Main.java

public static double round(double num) {
    BigDecimal b = new BigDecimal(num);
    BigDecimal rounded = b.setScale(2, RoundingMode.HALF_EVEN);
    return rounded.doubleValue();

    //return num;
}