Package java.math

Examples of java.math.BigDecimal.compareTo()


            value = (int) temp;
        } else if (a instanceof BigDecimal) {
            BigDecimal bd = ((BigDecimal) a);

            if (bd.compareTo(MAX_INT) > 0 || bd.compareTo(MIN_INT) < 0) {
                throw Error.error(ErrorCode.X_22003);
            }

            value = bd.intValue();
        } else if (a instanceof Double || a instanceof Float) {
View Full Code Here


            value = (int) temp;
        } else if (a instanceof BigDecimal) {
            BigDecimal bd = ((BigDecimal) a);

            if (bd.compareTo(MAX_INT) > 0 || bd.compareTo(MIN_INT) < 0) {
                throw Error.error(ErrorCode.X_22003);
            }

            value = bd.intValue();
        } else if (a instanceof Double || a instanceof Float) {
View Full Code Here

        } else if (a instanceof Long) {
            return (Long) a;
        } else if (a instanceof BigDecimal) {
            BigDecimal bd = (BigDecimal) a;

            if (bd.compareTo(MAX_LONG) > 0 || bd.compareTo(MIN_LONG) < 0) {
                throw Error.error(ErrorCode.X_22003);
            }

            return ValuePool.getLong(bd.longValue());
        } else if (a instanceof Double || a instanceof Float) {
View Full Code Here

        } else if (a instanceof Long) {
            return (Long) a;
        } else if (a instanceof BigDecimal) {
            BigDecimal bd = (BigDecimal) a;

            if (bd.compareTo(MAX_LONG) > 0 || bd.compareTo(MIN_LONG) < 0) {
                throw Error.error(ErrorCode.X_22003);
            }

            return ValuePool.getLong(bd.longValue());
        } else if (a instanceof Double || a instanceof Float) {
View Full Code Here

            value = bd.doubleValue();

            int        signum = bd.signum();
            BigDecimal bdd    = new BigDecimal(value + signum);

            if (bdd.compareTo(bd) != signum) {
                throw Error.error(ErrorCode.X_22003);
            }
        } else {
            value = ((Number) a).doubleValue();
        }
View Full Code Here

            value = bd.doubleValue();

            int        signum = bd.signum();
            BigDecimal bdd    = new BigDecimal(value + signum);

            if (bdd.compareTo(bd) != signum) {
                throw Error.error(ErrorCode.X_22003);
            }
        } else if (a instanceof Number) {
            value = ((Number) a).doubleValue();
        } else {
View Full Code Here

            } else {
                return (long) f;
            }
        } else if (num instanceof BigDecimal) {
            BigDecimal bd = ((BigDecimal) num).setScale(0, BigDecimal.ROUND_HALF_UP);
            if (bd.compareTo(BIG_DECIMAL_LONG_MAX) > 0 || bd.compareTo(BIG_DECIMAL_LONG_MIN) < 0) {
                throw new TemplateModelException(
                        "Number doesn't fit into a 64 bit signed integer (long): "
                        + bd);
            } else {
                return bd.longValue();
View Full Code Here

            } else {
                return (long) f;
            }
        } else if (num instanceof BigDecimal) {
            BigDecimal bd = ((BigDecimal) num).setScale(0, BigDecimal.ROUND_HALF_UP);
            if (bd.compareTo(BIG_DECIMAL_LONG_MAX) > 0 || bd.compareTo(BIG_DECIMAL_LONG_MIN) < 0) {
                throw new TemplateModelException(
                        "Number doesn't fit into a 64 bit signed integer (long): "
                        + bd);
            } else {
                return bd.longValue();
View Full Code Here

          sum = sum.add(new BigDecimal(values.get(i)));
        return sum.floatValue();
      case MIN:
        BigDecimal minimum = new BigDecimal(values.get(0));
        for (int i = 1; i < values.size(); ++i)
          if (minimum.compareTo(new BigDecimal(values.get(i))) > 0)
            minimum = new BigDecimal(values.get(i));
        return minimum.floatValue();
      case MAX:
        BigDecimal maximum = new BigDecimal(values.get(0));
        for (int i = 1; i < values.size(); ++i)
View Full Code Here

            minimum = new BigDecimal(values.get(i));
        return minimum.floatValue();
      case MAX:
        BigDecimal maximum = new BigDecimal(values.get(0));
        for (int i = 1; i < values.size(); ++i)
          if (maximum.compareTo(new BigDecimal(values.get(i))) < 0)
            maximum = new BigDecimal(values.get(i));
        return maximum.floatValue();
      case FIRST:
        return values.get(0);
      case LAST:
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.