@Override public Value negate() { return ValueDouble.get(-value); }
/** * Get or create double value for the given double. * * @param d the double * @return the value */ public static ValueDouble get(double d) { if (d == 1.0) { return ONE; } else if (d == 0.0) { // unfortunately, -0.0 == 0.0, but we don't want to return // 0.0 in this case if (Double.doubleToLongBits(d) == ZERO_BITS) { return ZERO; } } else if (Double.isNaN(d)) { return NAN; } return (ValueDouble) cache(new ValueDouble(d)); }
@Override public boolean equals(Object other) { if (!(other instanceof ValueDouble)) { return false; } return compareSecure((ValueDouble) other, null) == 0; }
@Override public String getSQL() { if (value == Double.POSITIVE_INFINITY) { return "POWER(0, -1)"; } else if (value == Double.NEGATIVE_INFINITY) { return "(-POWER(0, -1))"; } else if (Double.isNaN(value)) { return "SQRT(-1)"; } String s = getString(); if (s.equals("-0.0")) { return "-CAST(0 AS DOUBLE)"; } return s; }
@Override public Value add(Value v) { ValueDouble v2 = (ValueDouble) v; return ValueDouble.get(value + v2.value); }
@Override public Value multiply(Value v) { ValueDouble v2 = (ValueDouble) v; return ValueDouble.get(value * v2.value); }
@Override public Value subtract(Value v) { ValueDouble v2 = (ValueDouble) v; return ValueDouble.get(value - v2.value); }
return ValueNull.INSTANCE; v = ValueDouble.get(Math.sqrt(m2 / count)); break; return ValueNull.INSTANCE; v = ValueDouble.get(Math.sqrt(m2 / (count - 1))); break; return ValueNull.INSTANCE; v = ValueDouble.get(m2 / count); break; return ValueNull.INSTANCE; v = ValueDouble.get(m2 / (count - 1)); break;
/** * Sets the value of a parameter. * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @throws SQLException if this object is closed */ @Override public void setDouble(int parameterIndex, double x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setDouble(" + parameterIndex + ", " + x + "d);"); } setParameter(parameterIndex, ValueDouble.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
/** * Updates a column in the current or insert row. * * @param columnIndex (1,2,...) * @param x the value * @throws SQLException if the result set is closed or not updatable */ @Override public void updateDouble(int columnIndex, double x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateDouble(" + columnIndex + ", " + x + "d);"); } update(columnIndex, ValueDouble.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
/** * Updates a column in the current or insert row. * * @param columnLabel the column label * @param x the value * @throws SQLException if the result set is closed or not updatable */ @Override public void updateDouble(String columnLabel, double x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateDouble(" + quote(columnLabel) + ", " + x + "d);"); } update(columnLabel, ValueDouble.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
double value = rs.getDouble(columnIndex); v = rs.wasNull() ? (Value) ValueNull.INSTANCE : ValueDouble.get(value); break;
return ValueFloat.get(((Float) x).floatValue()); } else if (x instanceof Double) { return ValueDouble.get(((Double) x).doubleValue()); } else if (x instanceof byte[]) { return ValueBytes.get((byte[]) x);
break; case ACOS: result = ValueDouble.get(Math.acos(v0.getDouble())); break; case ASIN: result = ValueDouble.get(Math.asin(v0.getDouble())); break; case ATAN: result = ValueDouble.get(Math.atan(v0.getDouble())); break; case CEILING: result = ValueDouble.get(Math.ceil(v0.getDouble())); break; case COS: result = ValueDouble.get(Math.cos(v0.getDouble())); break; case COSH: result = ValueDouble.get(Math.cosh(v0.getDouble())); break; case COT: { result = ValueDouble.get(1. / d); break; result = ValueDouble.get(Math.toDegrees(v0.getDouble())); break; case EXP: result = ValueDouble.get(Math.exp(v0.getDouble())); break;
switch (getType()) { case BOOLEAN: return ValueDouble.get(getBoolean().booleanValue() ? 1 : 0); case BYTE: return ValueDouble.get(getByte()); case SHORT: return ValueDouble.get(getShort()); case INT: return ValueDouble.get(getInt()); case LONG: return ValueDouble.get(getLong()); case DECIMAL: return ValueDouble.get(getBigDecimal().doubleValue()); case FLOAT: return ValueDouble.get(getFloat()); return ValueStringFixed.get(s); case DOUBLE: return ValueDouble.get(Double.parseDouble(s.trim())); case FLOAT: return ValueFloat.get(Float.parseFloat(s.trim()));
switch (info.type) { case ATAN2: result = ValueDouble.get( Math.atan2(v0.getDouble(), v1.getDouble())); break; result = ValueDouble.get(Math.pow( v0.getDouble(), v1.getDouble())); break; case ROUND: { double f = v1 == null ? 1. : Math.pow(10., v1.getDouble()); result = ValueDouble.get(Math.round(v0.getDouble() * f) / f); break; double f = Math.pow(10., p); double g = d * f; result = ValueDouble.get(((d < 0) ? Math.ceil(g) : Math.floor(g)) / f);