Examples of longValueExact()


Examples of java.math.BigDecimal.longValueExact()

            // Strip off fraction part by converting via BigInteger
            // lest longValueExact will throw ArithmeticException
            BigDecimal tmp = new BigDecimal(
                getBigDecimal(buffer, offset, precision, scale).toBigInteger());
            // throws ArithmeticException if overflow:
            return tmp.longValueExact();
        }
    }

    //--------------entry points for runtime representation-----------------------
View Full Code Here

Examples of java.math.BigDecimal.longValueExact()

            BigDecimal bd = new BigDecimal(number);
            BigDecimal denominator = BigDecimal.ONE.scaleByPowerOfTen(bd.scale());
            BigDecimal numerator = bd.multiply(denominator);

            try {
                yaccValue = new RationalNode(getPosition(), numerator.longValueExact(), denominator.longValueExact());
            } catch (ArithmeticException ae) {
                // FIXME: Rational supports Bignum numerator and denominator
                throw new SyntaxException(PID.RATIONAL_OUT_OF_RANGE, getPosition(), getCurrentLine(), "Rational (" + numerator + "/" + denominator + ") out of range.");
            }
            return Tokens.tRATIONAL;
View Full Code Here

Examples of java.math.BigDecimal.longValueExact()

                return value;
            }
            if (value instanceof BigDecimal) {
                BigDecimal bigDecimal = (BigDecimal) value;
                try {
                    return bigDecimal.longValueExact();

                } catch (ArithmeticException e) {
                    // rowset.10=Data Type Mismatch
                    throw new SQLException(Messages.getString("rowset.10")); //$NON-NLS-1$
                }
View Full Code Here

Examples of java.math.BigDecimal.longValueExact()

            // if it's bigger than a double it can't be narrowed
            if (bigd.compareTo(BIGD_DOUBLE_MAX_VALUE) > 0) {
                return original;
            } else {
                try {
                    long l = bigd.longValueExact();
                    // coerce to int when possible (int being so often used in method parms)
                    if (narrowAccept(narrow, Integer.class)
                            && l <= Integer.MAX_VALUE
                            && l >= Integer.MIN_VALUE) {
                        return Integer.valueOf((int) l);
View Full Code Here

Examples of java.math.BigDecimal.longValueExact()

    if (param instanceof BigDecimal) {    // BigInteger is not supported
      BigDecimal b;
      try {
        b = ((BigDecimal)param).setScale(0, BigDecimal.ROUND_DOWN);
        try {
          return b.longValueExact();
        } catch (Exception e) {
        }
      } catch (Exception e) {
        throw new ParseException(e.getMessage());
      }
View Full Code Here

Examples of java.math.BigDecimal.longValueExact()

      param = parse((String)param);
    }
    if (param instanceof BigDecimal) {    // BigInteger is not supported
      BigDecimal b = ((BigDecimal)param).setScale(0, BigDecimal.ROUND_CEILING);
      try {
        return b.longValueExact();
      } catch (ArithmeticException e) {
      }
      return b;
    }
    if (param instanceof Double || param instanceof Float) {
View Full Code Here

Examples of java.math.BigDecimal.longValueExact()

      param = parse((String)param);
    }
    if (param instanceof BigDecimal) {    // BigInteger is not supported
      BigDecimal b = ((BigDecimal)param).setScale(0, BigDecimal.ROUND_FLOOR);
      try {
        return b.longValueExact();
      } catch (ArithmeticException e) {
      }
      return b;
    }
    if (param instanceof Double || param instanceof Float) {
View Full Code Here

Examples of java.math.BigDecimal.longValueExact()

      param = parse((String)param);
    }
    if (param instanceof BigDecimal) {    // BigInteger is not supported
      BigDecimal b = ((BigDecimal)param).setScale(0, BigDecimal.ROUND_HALF_UP);
      try {
        return b.longValueExact();
      } catch (ArithmeticException e) {
      }
      return b;
    }
    if (param instanceof Double || param instanceof Float) {
View Full Code Here

Examples of java.math.BigDecimal.longValueExact()

        private long convertFromFraction(BigDecimal fraction) {
            ValueRange range = field.range();
            BigDecimal minBD = BigDecimal.valueOf(range.getMinimum());
            BigDecimal rangeBD = BigDecimal.valueOf(range.getMaximum()).subtract(minBD).add(BigDecimal.ONE);
            BigDecimal valueBD = fraction.multiply(rangeBD).setScale(0, RoundingMode.FLOOR).add(minBD);
            return valueBD.longValueExact();
        }

        @Override
        public String toString() {
            String decimal = (decimalPoint ? ",DecimalPoint" : "");
View Full Code Here

Examples of java.math.BigDecimal.longValueExact()

     * @return this DataWord converted to a long.
     * @throws ArithmeticException - if this will not fit in a long.
     */
    public long longValue() {
      BigDecimal tmpValue = new BigDecimal(this.value());
        return tmpValue.longValueExact();
    }

    public BigInteger sValue() {
        return new BigInteger(data);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.