List of usage examples for java.lang Double toString
public static String toString(double d)
From source file:Main.java
public static double sub(double v1, double v2) { BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.subtract(b2).doubleValue(); }
From source file:Main.java
private static double getdPoint(double num) { double d = num; int fInt = (int) d; BigDecimal b1 = new BigDecimal(Double.toString(d)); BigDecimal b2 = new BigDecimal(Integer.toString(fInt)); double dPoint = b1.subtract(b2).floatValue(); return dPoint; }
From source file:Main.java
public static double getdPoint(double num) { double d = num; int fInt = (int) d; BigDecimal b1 = new BigDecimal(Double.toString(d)); BigDecimal b2 = new BigDecimal(Integer.toString(fInt)); double dPoint = b1.subtract(b2).floatValue(); return dPoint; }
From source file:Main.java
public static String doubleArr2String(Double[] doubleArray, String delimeter) { String str = ""; for (int i = 0; i < doubleArray.length; i++) { str += delimeter + Double.toString(doubleArray[i]); }// www . j av a2s. co m if (!str.isEmpty()) str = str.substring(1); return str; }
From source file:Main.java
@SuppressLint("DefaultLocale") public static String getPriceString(double price) { BigDecimal a1 = new BigDecimal(Double.toString(price)); return String.valueOf(a1.doubleValue()); }
From source file:Main.java
public static String formatNumber(int number) { double kilo = ((double) number) / 1000; if (kilo > 1) { BigDecimal result = new BigDecimal(Double.toString(kilo)); return result.setScale(1, BigDecimal.ROUND_HALF_UP).toPlainString() + "k"; } else {//w w w . j av a 2s. co m return number + ""; } }
From source file:Main.java
/** * Sets an attribute on the specified node, with the given name and value *//*from w ww. j a va 2s . co m*/ public static void setDblValue(Node node, String name, double value) { setStrValue(node, name, Double.toString(value)); }
From source file:Main.java
public static final double round(double v, int scale) { if (scale < 0) { throw new IllegalArgumentException("The scale must be a positive integer or zero"); }/*from www . j av a 2s . c om*/ BigDecimal b = new BigDecimal(Double.toString(v)); BigDecimal one = new BigDecimal("1"); return (b.divide(one, scale, BigDecimal.ROUND_HALF_UP)).doubleValue(); }
From source file:Main.java
public static double div(double v1, double v2, int scale) { if (scale < 0) { throw new IllegalArgumentException("The scale must be a positive integer or zero"); }/* w w w . j a va2 s . c om*/ BigDecimal b1 = new BigDecimal(Double.toString(v1)); BigDecimal b2 = new BigDecimal(Double.toString(v2)); return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue(); }
From source file:Main.java
public static double round(double paramDouble, int paramInt) { if (paramInt < 0) { throw new IllegalArgumentException("The scale must be a positive integer or zero"); }/*from ww w. j ava2 s . c om*/ return new BigDecimal(Double.toString(paramDouble)).divide(new BigDecimal("1"), paramInt, 5).doubleValue(); }