Package java.math

Examples of java.math.BigDecimal.longValue()


     * @see NumericValue#hashCode
     */

    public int hashCode() {
        BigDecimal round = value.setScale(0, BigDecimal.ROUND_DOWN);
        long value = round.longValue();
        if (value > Integer.MIN_VALUE && value < Integer.MAX_VALUE) {
            return (int)value;
        } else {
            return new Double(this.getDoubleValue()).hashCode();
        }
View Full Code Here


       ** This loses the fractional part, but it probably doesn't
       ** matter for numbers that are big enough to overflow a double -
       ** it's probably rare for numbers this big to be different only in
       ** their fractional parts.
       */
      longVal = localValue.longValue();
    }
    else
    {
      longVal = (long) doubleVal;
      if (longVal != doubleVal)
View Full Code Here

      synchronized (max_uid_st) {
        rs = max_uid_st.executeQuery();
        if (rs.next()) {
          BigDecimal max_uid = rs.getBigDecimal(1);
          //System.out.println("MAX UID = " + max_uid.longValue());
        return max_uid.longValue();
        } else {
          //System.out.println("MAX UID = -1!!!!");
          return -1;
        } // end of else
      }
View Full Code Here

                BigDecimal intlit = new BigDecimal
                    (node.text.endsWith("l") || node.text.endsWith("L")
                        ? node.text.substring(0, node.text.length() - 1)
                        : node.text).
                    multiply(new BigDecimal(negative(node)));
                return factory.newLiteral(Long.valueOf(intlit.longValue()),
                    Literal.TYPE_NUMBER);

            case JJTDECIMALLITERAL:
                BigDecimal declit = new BigDecimal
                    (node.text.endsWith("d") || node.text.endsWith("D") ||
View Full Code Here

    // this matches DB2 UDB behaviour

    if (   (localValue.compareTo(SQLDecimal.MINLONG_MINUS_ONE) == 1)
      && (localValue.compareTo(SQLDecimal.MAXLONG_PLUS_ONE) == -1)) {

      return localValue.longValue();
    }

    throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "BIGINT");
  }
View Full Code Here

        // fractions
        if (_fs != null && (_fs.signum() < 0 || _fs.compareTo(GDate._one) >= 0))
        {
            BigDecimal bdcarry = _fs.setScale(0, BigDecimal.ROUND_FLOOR);
            _fs = _fs.subtract(bdcarry);
            carry = bdcarry.longValue();
        }

        if (carry != 0 || _s < 0 || _s > 59 || _m < 0 || _m > 50 || _h < 0 || _h > 23)
        {
            // seconds
View Full Code Here

                String msg = "Unable to provide an id.  The next id would " +
                    "be greater than the id data type allows.";
                getLogger().error( msg );
                throw new IdException( msg );
            }
            nextId = bd.longValue();
        }
        else
        {
            // Use long data type
            synchronized( m_semaphore )
View Full Code Here

            shippableWeight = BigDecimal.ONE;
        }
        if ((dhlShipmentDetailCode.equals("G") && shippableWeight.compareTo(new BigDecimal("999")) > 0) || (shippableWeight.compareTo(new BigDecimal("150")) > 0)) {
            return ServiceUtil.returnError("Cannot get DHL Estimate: Shippable weight cannot be greater than 999 lbs for ground or 150 lbs for all other services.");
        }
        String weight = (Integer.valueOf((int) shippableWeight.longValue())).toString();

        // create AccessRequest XML doc using FreeMarker template
        String templateName = UtilProperties.getPropertyValue(shipmentPropertiesFile, "shipment.template.dhl.rate.estimate");
        if ((templateName == null) || (templateName.trim().length() == 0)) {
            return ServiceUtil.returnError("Cannot get DHL Estimate: DHL Rate template not configured (shipment.template.dhl.rate.estimate");
View Full Code Here

      result = new LongPropertyInfo((Long)obj);
    } else if (obj instanceof Double) {// float and double are both stored as 64-bit double precision, IEEE 754
      result = new DoublePropertyInfo((Double)obj);
    } else if (obj instanceof BigDecimal) {  // most processed fields will be bigdecimal
      BigDecimal bd = (BigDecimal) obj;
      if ((double)bd.longValue() == bd.doubleValue()) {  // try to make it long if there is no lose of precision
        result = new LongPropertyInfo(bd.longValue());
      } else {
        result = new DoublePropertyInfo(bd.doubleValue())
      }
    } else if (obj instanceof User) {
View Full Code Here

    } else if (obj instanceof Double) {// float and double are both stored as 64-bit double precision, IEEE 754
      result = new DoublePropertyInfo((Double)obj);
    } else if (obj instanceof BigDecimal) {  // most processed fields will be bigdecimal
      BigDecimal bd = (BigDecimal) obj;
      if ((double)bd.longValue() == bd.doubleValue()) {  // try to make it long if there is no lose of precision
        result = new LongPropertyInfo(bd.longValue());
      } else {
        result = new DoublePropertyInfo(bd.doubleValue())
      }
    } else if (obj instanceof User) {
      User user = (User)obj;
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.