@Override public Value multiply(Value v) { ValueFloat v2 = (ValueFloat) v; return ValueFloat.get(value * v2.value); }
@Override public boolean equals(Object other) { if (!(other instanceof ValueFloat)) { return false; } return compareSecure((ValueFloat) other, null) == 0; }
@Override public String getSQL() { if (value == Float.POSITIVE_INFINITY) { return "POWER(0, -1)"; } else if (value == Float.NEGATIVE_INFINITY) { return "(-POWER(0, -1))"; } else if (Double.isNaN(value)) { // NaN return "SQRT(-1)"; } String s = getString(); if (s.equals("-0.0")) { return "-CAST(0 AS REAL)"; } return s; }
public float getFloat() { return ((ValueFloat) convertTo(Value.FLOAT)).getFloat(); }
/** * Get or create float value for the given float. * * @param d the float * @return the value */ public static ValueFloat get(float d) { if (d == 1.0F) { return ONE; } else if (d == 0.0F) { // unfortunately, -0.0 == 0.0, but we don't want to return // 0.0 in this case if (Float.floatToIntBits(d) == ZERO_BITS) { return ZERO; } } return (ValueFloat) Value.cache(new ValueFloat(d)); }
@Override public Value add(Value v) { ValueFloat v2 = (ValueFloat) v; return ValueFloat.get(value + v2.value); }
@Override public Value subtract(Value v) { ValueFloat v2 = (ValueFloat) v; return ValueFloat.get(value - v2.value); }
@Override public Value negate() { return ValueFloat.get(-value); }
@Override public Value readValue(ByteBuffer buff, int tag) { switch (tag) { case TAG_FLOAT_0: return ValueFloat.get(0f); case TAG_FLOAT_1: return ValueFloat.get(1f); case TAG_FLOAT_FIXED: return ValueFloat.get(buff.getFloat()); } return ValueFloat.get(Float.intBitsToFloat(Integer.reverse(DataUtils.readVarInt(buff)))); } };
/** * 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 setFloat(int parameterIndex, float x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setFloat(" + parameterIndex + ", " + x + "f);"); } setParameter(parameterIndex, ValueFloat.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 updateFloat(int columnIndex, float x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateFloat(" + columnIndex + ", " + x + "f);"); } update(columnIndex, ValueFloat.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 updateFloat(String columnLabel, float x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateFloat(" + quote(columnLabel) + ", " + x + "f);"); } update(columnLabel, ValueFloat.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
v = rs.wasNull() ? (Value) ValueNull.INSTANCE : ValueFloat.get(value); break;
return ValueShort.get(((Short) x).shortValue()); } else if (x instanceof Float) { return ValueFloat.get(((Float) x).floatValue()); } else if (x instanceof Double) { return ValueDouble.get(((Double) x).doubleValue());
switch (getType()) { case BOOLEAN: return ValueFloat.get(getBoolean().booleanValue() ? 1 : 0); case BYTE: return ValueFloat.get(getByte()); case SHORT: return ValueFloat.get(getShort()); case INT: return ValueFloat.get(getInt()); case LONG: return ValueFloat.get(getLong()); case DECIMAL: return ValueFloat.get(getBigDecimal().floatValue()); case DOUBLE: return ValueFloat.get((float) getDouble()); return ValueDouble.get(Double.parseDouble(s.trim())); case FLOAT: return ValueFloat.get(Float.parseFloat(s.trim())); case CLOB: return ValueLob.createSmallLob(CLOB, s.getBytes(Constants.UTF8));
return ValueDouble.get(readDouble()); case Value.FLOAT: return ValueFloat.get(readFloat()); case Value.SHORT: return ValueShort.get((short) readInt());