Example usage for java.lang Double toString

List of usage examples for java.lang Double toString

Introduction

In this page you can find the example usage for java.lang Double toString.

Prototype

public static String toString(double d) 

Source Link

Document

Returns a string representation of the double argument.

Usage

From source file:Main.java

public static Double mul(Number value1, Number value2) {
    BigDecimal b1 = new BigDecimal(Double.toString(value1.doubleValue()));
    BigDecimal b2 = new BigDecimal(Double.toString(value2.doubleValue()));
    return b1.multiply(b2).doubleValue();
}

From source file:Main.java

public static Double add(Number value1, Number value2) {
    BigDecimal b1 = new BigDecimal(Double.toString(value1.doubleValue()));
    BigDecimal b2 = new BigDecimal(Double.toString(value2.doubleValue()));
    return b1.add(b2).doubleValue();
}

From source file:Main.java

public static double remainder(double v1, double v2) {

    BigDecimal val1 = new BigDecimal(Double.toString(v1 % v2));
    double val = val1.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
    return val;
}

From source file:Main.java

public static int compareTo(Number value1, Number value2) {
    BigDecimal b1 = new BigDecimal(Double.toString(value1.doubleValue()));
    BigDecimal b2 = new BigDecimal(Double.toString(value2.doubleValue()));
    return b1.compareTo(b2);
}

From source file:Main.java

public static double sub2(double v1, double v2, double v3) {
    BigDecimal b1 = new BigDecimal(Double.toString(v1));
    BigDecimal b2 = new BigDecimal(Double.toString(v2));
    BigDecimal b3 = new BigDecimal(Double.toString(v3));
    return b1.subtract(b2).subtract(b3).doubleValue();
}

From source file:Main.java

public static BigDecimal mulBigDecimal(double v1, double v2) {
    BigDecimal b1 = new BigDecimal(Double.toString(v1));
    BigDecimal b2 = new BigDecimal(Double.toString(v2));
    return b1.multiply(b2);
}

From source file:Main.java

public static double mulDouble(double v1, double v2) {

    BigDecimal b1 = new BigDecimal(Double.toString(v1));

    BigDecimal b2 = new BigDecimal(Double.toString(v2));

    return b1.multiply(b2).doubleValue();

}

From source file:Main.java

public static int convertDOubleToInt(Double value) {
    String valueString = Double.toString(value);

    for (int i = 0; i < valueString.length(); i++) {
        if (valueString.charAt(i) == '.') {
            valueString = valueString.substring(0, i);
            break;
        }//from  w w w  .j av a  2  s  . c  om
    }

    int valueInteger = Integer.parseInt(valueString);

    return valueInteger;
}

From source file:Main.java

public static double mulddd(double value1, double value2, double value3) {
    BigDecimal b1 = new BigDecimal(Double.toString(value1));
    BigDecimal b2 = new BigDecimal(Double.toString(value2));
    BigDecimal b3 = new BigDecimal(Double.toString(value3));
    return b1.multiply(b2).multiply(b3).doubleValue();
}

From source file:Main.java

public static double add(double v1, double v2) {
    BigDecimal b1 = new BigDecimal(Double.toString(v1));
    BigDecimal b2 = new BigDecimal(Double.toString(v2));
    return b1.add(b2).doubleValue();
}