List of usage examples for java.lang Double toString
public String toString()
From source file:Main.java
public static void main(String[] args) { Double dObj = new Double(10.25); String str = dObj.toString(); System.out.println(str);/*from w w w .ja v a 2 s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { Double d = new Double("5.3000000001"); String retval = d.toString(); System.out.println("Value = " + retval); }
From source file:au.edu.jcu.usb.USBPlotFrame.java
/** * Creates the XY Plot, and then listens to the USB interface (/dev/ttyUSB0) and plots the * read data. The USB Interface is read every second. * * @param args// w w w .ja v a 2s . c o m * @throws Exception */ public static void main(String args[]) throws Exception { USBInterface myUSB = new USBInterface("/dev/ttyUSB0"); USBPlotFrame frame = new USBPlotFrame(); frame.setVisible(true); int count = 0; while (true) { Thread.sleep(1000); List<Double> values = myUSB.readAsDoubleArray(); for (Double val : values) { System.out.println(val.toString()); frame.addPoint(count++, val); } } }
From source file:com.yarsquidy.x12.example.exampleSpringParseX12FileOne.java
public static void main(String[] args) { X12 x12 = null;/*from w w w . ja v a 2 s .c o m*/ Resource xmlResource = new FileSystemResource("./target/classes/cf/appContext_835_004010X091.xml"); BeanFactory factory = new XmlBeanFactory(xmlResource); Cf cf = (Cf) factory.getBean("bean_X12"); Double totalChargeAmount = 0.0; URL url = exampleSpringParseX12FileOne.class.getClass() .getResource("/org/pb/x12/example/example835One.txt"); File f1 = new File(url.getFile()); Parser parser = new X12Parser(cf); try { x12 = (X12) parser.parse(f1); // calculate the total charge amount List<Loop> loops = x12.findLoop("2100"); for (Loop loop : loops) { for (Segment s : loop) { if (s.getElement(0).equals("CLP")) { totalChargeAmount = totalChargeAmount + Double.parseDouble(s.getElement(3)); } } } System.out.println("Total Charged Amount = " + totalChargeAmount.toString()); // calculate the total charge amount - alternate method totalChargeAmount = 0.0; List<Segment> segments = x12.findSegment("CLP"); for (Segment s : segments) { totalChargeAmount = totalChargeAmount + Double.parseDouble(s.getElement(3)); } System.out.println("Total Charged Amount = " + totalChargeAmount.toString()); } catch (Exception e1) { e1.printStackTrace(); } }
From source file:Main.java
public static Double sub(Double v1, Double v2) { BigDecimal b1 = new BigDecimal(v1.toString()); BigDecimal b2 = new BigDecimal(v2.toString()); return Double.valueOf(b1.subtract(b2).doubleValue()); }
From source file:Main.java
public static Double add(Double v1, Double v2) { BigDecimal b1 = new BigDecimal(v1.toString()); BigDecimal b2 = new BigDecimal(v2.toString()); return Double.valueOf(b1.add(b2).doubleValue()); }
From source file:Main.java
public static Double mul(Double v1, Double v2) { BigDecimal b1 = new BigDecimal(v1.toString()); BigDecimal b2 = new BigDecimal(v2.toString()); return Double.valueOf(b1.multiply(b2).doubleValue()); }
From source file:Main.java
public static String doubleParseToString(double d1) { Double d = new Double(d1); BigDecimal bd = new BigDecimal(d.toString()); return bd.toPlainString(); }
From source file:Main.java
public static Double div(Double v1, Double v2) { BigDecimal b1 = new BigDecimal(v1.toString()); BigDecimal b2 = new BigDecimal(v2.toString()); return Double.valueOf(b1.divide(b2, DEF_DIV_SCALE, BigDecimal.ROUND_HALF_UP).doubleValue()); }
From source file:Main.java
public static void setDoubleAttribute(Element el, String attr, Double value) { if (null != value) { el.setAttribute(attr, value.toString()); }/*from w ww .j ava 2 s . c o m*/ }