List of usage examples for java.lang Double parseDouble
public static double parseDouble(String s) throws NumberFormatException
From source file:Main.java
public static double getFormatted(double d) { DecimalFormat df = new DecimalFormat("#.000000000000000"); String s = df.format(d);//w w w. j a va 2 s. c om double d2 = Double.parseDouble(s); return d2; }
From source file:Main.java
public static double parseDouble(String str, double defaultValue) { double i = defaultValue; if (str != null && !str.equals("")) { try {//w w w .ja va2s .c om i = Double.parseDouble(str); } catch (NumberFormatException e) { // TODO Auto-generated catch block i = defaultValue; } } return i; }
From source file:Main.java
public static double divAddGoods(String value1, String value2) { if ("0.".equals(value2)) { value2 = "1"; }// w ww .ja v a2s .co m double v1 = Double.parseDouble(value1); double v2 = Double.parseDouble(value2); BigDecimal b1 = new BigDecimal(v1); BigDecimal b2 = new BigDecimal((v2)); return b1.divide(b2, 2, BigDecimal.ROUND_HALF_UP).doubleValue(); }
From source file:Main.java
public static String formatPrice(String price) { String tempPrice = "0"; if (null != price && !"".equals(price)) { double d = Double.parseDouble(price); if (d != 0) { DecimalFormat df = new DecimalFormat("##0.00"); tempPrice = df.format(Double.parseDouble(price)); }// www.j a v a2 s . c om } return tempPrice; }
From source file:Main.java
public static double[] StrArrayToDouble(String[] arr) { double[] nums = new double[arr.length]; for (int i = 0; i < nums.length; i++) { nums[i] = Double.parseDouble(arr[i]); }/* w ww. j a v a2 s. c o m*/ return nums; }
From source file:Main.java
public static double formatDouble(double raw) { String res = df.format(raw).replaceAll(",", "."); return Double.parseDouble(res); }
From source file:Main.java
public static double position(String s, List<String> ss) { double p = -1d; for (int i = 0; i < ss.size(); i++) { if (s.equals(ss.get(i))) { p = Double.parseDouble(i + ""); break; }// www .ja v a 2s. c om } return p; }
From source file:Main.java
public static double parseDouble(String number) { try {/* w w w .j a v a2 s . c o m*/ return Double.parseDouble(number); } catch (Exception e) { return 0.0; } }
From source file:Main.java
public static String mode(String freq) { String ret = ""; double f = Double.parseDouble(freq); if (f > 1.8 && f < 1.843) ret = "CW"; else if (f >= 1.843 && f < 2.0) ret = "LSB"; else if (f >= 3.5 && f < 3.57) ret = "CW"; else if (f >= 3.57 && f < 3.6) ret = "RTTY"; else if (f >= 3.6 && f < 3.845) ret = "LSB"; else if (f >= 3.845 && f <= 3.88) ret = "SSTV"; else if (f > 3.88 && f < 3.9) ret = "AM"; else if (f > 3.9 && f < 4.0) ret = "LSB"; else if (f >= 7.0 && f < 7.04) ret = "CW"; else if (f >= 7.04 && f <= 7.045) ret = "RTTY"; else if (f > 7.045 && f < 7.07) ret = "CW"; else if (f >= 7.07 && f <= 7.075) ret = "PSK31"; else if (f > 7.075 && f <= 7.08) ret = "JT65"; else if (f > 7.08 && f < 7.125) ret = "CW"; else if (f >= 7.125 && f < 7.290) ret = "LSB"; else if (f >= 7.290 && f <= 7.3) ret = "AM"; else if (f >= 10.1 && f < 10.13) ret = "CW"; else if (f >= 10.13 && f <= 10.14) ret = "RTTY"; else if (f > 10.14 && f <= 10.15) ret = "CW"; else if (f >= 14.0 && f < 14.07) ret = "CW"; else if (f >= 14.07 && f <= 14.095) ret = "RTTY"; else if (f >= 14.095 && f < 14.15) ret = "CW"; else if (f >= 14.15 && f < 14.35) ret = "USB"; else if (f >= 18.068 && f < 18.11) ret = "CW"; else if (f >= 18.11 && f <= 18.168) ret = "USB"; else if (f >= 21.0 && f < 21.07) ret = "CW"; else if (f >= 21.07 && f < 21.11) ret = "RTTY"; else if (f >= 21.11 && f < 21.2) ret = "CW"; else if (f >= 21.2 && f <= 21.45) ret = "USB"; else if (f >= 24.890 && f < 24.93) ret = "CW"; else if (f >= 24.93 && f <= 24.99) ret = "USB"; else if (f >= 28.0 && f <= 28.3) ret = "CW"; else if (f >= 28.3 && f < 29.0) ret = "USB"; else if (f >= 29.0 && f < 29.2) ret = "AM"; else if (f >= 29.2 && f < 29.7) ret = "FM"; else if (f >= 50.0 && f < 50.1) ret = "CW"; else if (f >= 50.1 && f < 52.0) ret = "USB"; else if (f >= 52.0 && f <= 54.0) ret = "FM"; return ret;//from ww w. ja v a2s. c o m }
From source file:Main.java
public static Double toDecimal(Double value) { DecimalFormat df = new DecimalFormat("#.000000"); df.setRoundingMode(RoundingMode.DOWN); return Double.parseDouble(df.format(value)); }