private void validateLiteralAsDouble(SqlLiteral literal) { BigDecimal bd = (BigDecimal) literal.getValue(); double d = bd.doubleValue(); if (Double.isInfinite(d) || Double.isNaN(d)) { // overflow throw newValidationError(literal, RESOURCE.numberLiteralOutOfRange(Util.toScientificNotation(bd))); } // REVIEW jvs 4-Aug-2004: what about underflow? }
RESOURCE.numberLiteralOutOfRange(bd.toString()));
private void validateLiteralAsDouble(SqlLiteral literal) { BigDecimal bd = (BigDecimal) literal.getValue(); double d = bd.doubleValue(); if (Double.isInfinite(d) || Double.isNaN(d)) { // overflow throw newValidationError(literal, RESOURCE.numberLiteralOutOfRange(Util.toScientificNotation(bd))); } // REVIEW jvs 4-Aug-2004: what about underflow? }
private void validateLiteralAsDouble(SqlLiteral literal) { BigDecimal bd = (BigDecimal) literal.getValue(); double d = bd.doubleValue(); if (Double.isInfinite(d) || Double.isNaN(d)) { // overflow throw newValidationError(literal, RESOURCE.numberLiteralOutOfRange(Util.toScientificNotation(bd))); } // REVIEW jvs 4-Aug-2004: what about underflow? }
@SuppressWarnings("deprecation") @Override public int getIntLiteralOperand(int ordinal) { SqlNode node = call.operand(ordinal); final Object o = SqlLiteral.value(node); if (o instanceof BigDecimal) { BigDecimal bd = (BigDecimal) o; try { return bd.intValueExact(); } catch (ArithmeticException e) { throw SqlUtil.newContextException(node.pos, RESOURCE.numberLiteralOutOfRange(bd.toString())); } } throw new AssertionError(); }
@SuppressWarnings("deprecation") @Override public int getIntLiteralOperand(int ordinal) { SqlNode node = call.operand(ordinal); final Object o = SqlLiteral.value(node); if (o instanceof BigDecimal) { BigDecimal bd = (BigDecimal) o; try { return bd.intValueExact(); } catch (ArithmeticException e) { throw SqlUtil.newContextException(node.pos, RESOURCE.numberLiteralOutOfRange(bd.toString())); } } throw new AssertionError(); }
/** * Returns the long value of this literal. * * @param exact Whether the value has to be exact. If true, and the literal * is a fraction (e.g. 3.14), throws. If false, discards the * fractional part of the value. * @return Long value of this literal */ public long longValue(boolean exact) { switch (typeName) { case DECIMAL: case DOUBLE: BigDecimal bd = (BigDecimal) value; if (exact) { try { return bd.longValueExact(); } catch (ArithmeticException e) { throw SqlUtil.newContextException(getParserPosition(), RESOURCE.numberLiteralOutOfRange(bd.toString())); } } else { return bd.longValue(); } default: throw Util.unexpected(typeName); } }
/** * Returns the integer value of this literal. * * @param exact Whether the value has to be exact. If true, and the literal * is a fraction (e.g. 3.14), throws. If false, discards the * fractional part of the value. * @return Integer value of this literal */ public int intValue(boolean exact) { switch (typeName) { case DECIMAL: case DOUBLE: BigDecimal bd = (BigDecimal) value; if (exact) { try { return bd.intValueExact(); } catch (ArithmeticException e) { throw SqlUtil.newContextException(getParserPosition(), RESOURCE.numberLiteralOutOfRange(bd.toString())); } } else { return bd.intValue(); } default: throw Util.unexpected(typeName); } }
/** * Returns the integer value of this literal. * * @param exact Whether the value has to be exact. If true, and the literal * is a fraction (e.g. 3.14), throws. If false, discards the * fractional part of the value. * @return Integer value of this literal */ public int intValue(boolean exact) { switch (typeName) { case DECIMAL: case DOUBLE: BigDecimal bd = (BigDecimal) value; if (exact) { try { return bd.intValueExact(); } catch (ArithmeticException e) { throw SqlUtil.newContextException(getParserPosition(), RESOURCE.numberLiteralOutOfRange(bd.toString())); } } else { return bd.intValue(); } default: throw Util.unexpected(typeName); } }
/** * Returns the long value of this literal. * * @param exact Whether the value has to be exact. If true, and the literal * is a fraction (e.g. 3.14), throws. If false, discards the * fractional part of the value. * @return Long value of this literal */ public long longValue(boolean exact) { switch (typeName) { case DECIMAL: case DOUBLE: BigDecimal bd = (BigDecimal) value; if (exact) { try { return bd.longValueExact(); } catch (ArithmeticException e) { throw SqlUtil.newContextException(getParserPosition(), RESOURCE.numberLiteralOutOfRange(bd.toString())); } } else { return bd.longValue(); } default: throw Util.unexpected(typeName); } }
if (throwOnFailure) { throw callBinding.newError( RESOURCE.numberLiteralOutOfRange(value.toString()));
if (throwOnFailure) { throw callBinding.newError( RESOURCE.numberLiteralOutOfRange(value.toString()));
RESOURCE.numberLiteralOutOfRange(bd.toString()));
RESOURCE.numberLiteralOutOfRange(bd.toString()));