Example usage for com.google.gson JsonElement getAsDouble

List of usage examples for com.google.gson JsonElement getAsDouble

Introduction

In this page you can find the example usage for com.google.gson JsonElement getAsDouble.

Prototype

public double getAsDouble() 

Source Link

Document

convenience method to get this element as a primitive double value.

Usage

From source file:org.qcert.runtime.UnaryOperators.java

License:Apache License

public static JsonElement float_sqrt(JsonElement e) {
    return new JsonPrimitive(Math.sqrt(e.getAsDouble()));
}

From source file:org.qcert.runtime.UnaryOperators.java

License:Apache License

public static JsonElement float_exp(JsonElement e) {
    return new JsonPrimitive(Math.exp(e.getAsDouble()));
}

From source file:org.qcert.runtime.UnaryOperators.java

License:Apache License

public static JsonElement float_log(JsonElement e) {
    return new JsonPrimitive(Math.log(e.getAsDouble()));
}

From source file:org.qcert.runtime.UnaryOperators.java

License:Apache License

public static JsonElement float_log10(JsonElement e) {
    return new JsonPrimitive(Math.log10(e.getAsDouble()));
}

From source file:org.qcert.runtime.UnaryOperators.java

License:Apache License

public static JsonElement float_ceil(JsonElement e) {
    return new JsonPrimitive(Math.ceil(e.getAsDouble()));
}

From source file:org.qcert.runtime.UnaryOperators.java

License:Apache License

public static JsonElement float_floor(JsonElement e) {
    return new JsonPrimitive(Math.floor(e.getAsDouble()));
}

From source file:org.qcert.runtime.UnaryOperators.java

License:Apache License

public static JsonElement float_abs(JsonElement e) {
    return new JsonPrimitive(Math.abs(e.getAsDouble()));
}

From source file:org.qcert.runtime.UnaryOperators.java

License:Apache License

public static double float_sum_helper(JsonArray ec) {
    double acc = 0.0d;
    for (JsonElement elem : ec) {
        acc += elem.getAsDouble();
    }/*ww  w . jav  a 2s .  c om*/
    return acc;
}

From source file:org.qcert.runtime.UnaryOperators.java

License:Apache License

public static JsonElement float_list_min(JsonElement e) {
    final JsonArray ec = e.getAsJsonArray();
    double min = Double.MAX_VALUE;
    for (final JsonElement elem : ec) {
        final double eleml = elem.getAsDouble();
        if (eleml < min) {
            min = eleml;//  w w  w. ja  va  2s.  co  m
        }
    }
    return new JsonPrimitive(min);
}

From source file:org.qcert.runtime.UnaryOperators.java

License:Apache License

public static JsonElement float_list_max(JsonElement e) {
    final JsonArray ec = e.getAsJsonArray();
    double max = Double.MIN_VALUE;
    for (final JsonElement elem : ec) {
        final double eleml = elem.getAsDouble();
        if (eleml > max) {
            max = eleml;// ww w .j  a  v  a 2s.  c  om
        }
    }
    return new JsonPrimitive(max);
}