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

/**
 * Creates an element with content in the form of a double
 *///from   w  ww .  j  a  va 2s. c o m
public static Element createElement(Element parent, Document document, String name, double value) {
    return createElement(parent, document, name, Double.toString(value));
}

From source file:visual.FinalToolTipChartState.java

@Override
public String generateToolTip(XYDataset xyd, int i, int i1) {
    String s = Double.toString((double) Math.round(xyd.getYValue(i, i1) * 100000) / 100000);
    String actName = svc.getActionNameFor(i1);
    return actName + " (" + String.valueOf(i1) + ", " + s + ")";
}

From source file:mtsar.api.csv.WorkerRankingCSV.java

public static void write(Collection<WorkerRanking> rankings, OutputStream output) throws IOException {
    try (final Writer writer = new OutputStreamWriter(output, StandardCharsets.UTF_8)) {
        final Iterable<String[]> iterable = () -> rankings.stream().sorted(ORDER)
                .map(aggregation -> new String[] { Integer.toString(aggregation.getWorker().getId()), // worker_id
                        Double.toString(aggregation.getReputation()) // reputation
                }).iterator();//from w  ww  . ja v a2s  .c o  m

        FORMAT.withHeader(HEADER).print(writer).printRecords(iterable);
    }
}

From source file:visual.FinalToolTipChart.java

@Override
public String generateToolTip(XYDataset xyd, int i, int i1) {
    String s = Double.toString((double) Math.round(xyd.getYValue(i, i1) * 100000) / 100000);
    String actName = actValCont.getActionName(i1);
    return actName + " (" + String.valueOf(i1) + ", " + s + ")";
}

From source file:Main.java

/**
 * Puts the passed key and value into the map only if the value is not -1.
 * /*from  www .jav  a 2  s . c om*/
 * @param map Map to add key and value to.
 * @param key Map key.
 * @param value Map value, if -1 will not be added to map.
 */
public static void nullSafePut(final Map<String, String> map, final String key, final double value) {
    if (value != -1) {
        map.put(key, Double.toString(value));
    }
}

From source file:Main.java

/**
 * Flatten a double[] into an XmlSerializer.  The list can later be read back
 * with readThisDoubleArrayXml()./* w ww .java 2  s  .  c o m*/
 *
 * @param val  The double array to be flattened.
 * @param name Name attribute to include with this array's tag, or null for
 *             none.
 * @param out  XmlSerializer to write the array into.
 * @see #writeMapXml
 * @see #writeValueXml
 * @see #readThisIntArrayXml
 */
public static void writeDoubleArrayXml(double[] val, String name, XmlSerializer out)
        throws java.io.IOException {

    if (val == null) {
        out.startTag(null, "null");
        out.endTag(null, "null");
        return;
    }

    out.startTag(null, "double-array");
    if (name != null) {
        out.attribute(null, "name", name);
    }

    final int N = val.length;
    out.attribute(null, "num", Integer.toString(N));

    for (double aVal : val) {
        out.startTag(null, "item");
        out.attribute(null, "value", Double.toString(aVal));
        out.endTag(null, "item");
    }

    out.endTag(null, "double-array");
}

From source file:de.grobmeier.jjson.JSONNumber.java

/**
 * 
 */
public JSONNumber(double value) {
    this.value = Double.toString(value);
}

From source file:Main.java

void total(double first, double second, String ope) {
    String total;/*from ww  w.  j  ava  2 s. c om*/
    if (ope.equalsIgnoreCase("+")) {
        total1 = first + second;
        total = Double.toString(total1);
        textField.setText(total);
    } else if (ope.equalsIgnoreCase("-")) {
        total1 = first - second;
        total = Double.toString(total1);
        textField.setText(total);
    } else if (ope.equalsIgnoreCase("*")) {
        total1 = first * second;
        total = Double.toString(total1);
        textField.setText(total);
    } else if (ope.equalsIgnoreCase("/")) {
        total1 = first / second;
        total = Double.toString(total1);
        textField.setText(total);
    }
    clearfields();
}

From source file:Main.java

/**
 * Flatten a double[] into an XmlSerializer.  The list can later be read back
 * with readThisDoubleArrayXml().//w ww  .java 2 s  .  c o m
 *
 * @param val  The double array to be flattened.
 * @param name Name attribute to include with this array's tag, or null for
 *             none.
 * @param out  XmlSerializer to write the array into.
 * @see #writeMapXml
 * @see #writeValueXml
 * @see #readThisIntArrayXml
 */
public static final void writeDoubleArrayXml(double[] val, String name, XmlSerializer out)
        throws XmlPullParserException, IOException {

    if (val == null) {
        out.startTag(null, "null");
        out.endTag(null, "null");
        return;
    }

    out.startTag(null, "double-array");
    if (name != null) {
        out.attribute(null, "name", name);
    }

    final int N = val.length;
    out.attribute(null, "num", Integer.toString(N));

    for (int i = 0; i < N; i++) {
        out.startTag(null, "item");
        out.attribute(null, "value", Double.toString(val[i]));
        out.endTag(null, "item");
    }

    out.endTag(null, "double-array");
}

From source file:area.math.nm.lib.Interpolation.java

public String splineInterpolation(double x[], double y[], double input) {
    UnivariateInterpolator interpolator = new SplineInterpolator();
    UnivariateFunction function = interpolator.interpolate(x, y);
    double interpolationX = input;
    double interpolatedY = function.value(input);
    System.out.println("f(" + interpolationX + ") = " + interpolatedY);
    String result = new String(Double.toString(interpolatedY));
    return (result);
}