Package java.math

Examples of java.math.BigDecimal.longValue()


                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(new Long(intlit.longValue()),
                    Literal.TYPE_NUMBER);

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


        BigDecimal expected = new BigDecimal(d).setScale(0, mode);
        boolean isInBounds = expected.compareTo(MAX_LONG_AS_BIG_DECIMAL) <= 0
            & expected.compareTo(MIN_LONG_AS_BIG_DECIMAL) >= 0;

        try {
          assertEquals(expected.longValue(), DoubleMath.roundToLong(d, mode));
          assertTrue(isInBounds);
        } catch (ArithmeticException e) {
          assertFalse(isInBounds);
        }
      }
View Full Code Here

      BigDecimal expected = new BigDecimal(d).setScale(0, UNNECESSARY);
      boolean isInBounds = expected.compareTo(MAX_LONG_AS_BIG_DECIMAL) <= 0
          & expected.compareTo(MIN_LONG_AS_BIG_DECIMAL) >= 0;

      try {
        assertEquals(expected.longValue(), DoubleMath.roundToLong(d, UNNECESSARY));
        assertTrue(isInBounds);
      } catch (ArithmeticException e) {
        assertFalse(isInBounds);
      }
    }
View Full Code Here

        BigDecimal expected = new BigDecimal(d).setScale(0, mode);
        boolean isInBounds = expected.compareTo(MAX_LONG_AS_BIG_DECIMAL) <= 0
            & expected.compareTo(MIN_LONG_AS_BIG_DECIMAL) >= 0;

        try {
          assertEquals(expected.longValue(), DoubleMath.roundToLong(d, mode));
          assertTrue(isInBounds);
        } catch (ArithmeticException e) {
          assertFalse(isInBounds);
        }
      }
View Full Code Here

    // this matches DB2 UDB behaviour

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

      return localValue.longValue();
    }

    throw StandardException.newException(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE, "BIGINT");
  }
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

 
  public Long getNextId(String sequenceName) {
    SQLQuery query = session().createSQLQuery(
        String.format("SELECT %s.nextval FROM DUAL", sequenceName));
    BigDecimal id = (BigDecimal) query.uniqueResult();
    return id.longValue();
  }

  public T getById(Long id) throws DataException {
    return (T) component.load(getDomainClass(), id);
  }
View Full Code Here

        case TYPE_FLOAT:
            resultObj = Float.valueOf(resultValue.floatValue());
            break;
        case TYPE_LONG:
            resultValue = resultValue.setScale(0, roundingMode);
            resultObj = Long.valueOf(resultValue.longValue());
            break;
        case TYPE_INTEGER:
            resultValue = resultValue.setScale(0, roundingMode);
            resultObj = Integer.valueOf(resultValue.intValue());
            break;
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(new Long(intlit.longValue()),
                    Literal.TYPE_NUMBER);

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

    public void testGetLongOnDecimal() throws RepositoryException {
        BigDecimal bd1 = new BigDecimal(Long.MAX_VALUE);
        BigDecimal bd2 = new BigDecimal(Double.MIN_VALUE);

        assertEquals(bd1.longValue(), factory.create(bd1).getLong());
        assertEquals(bd2.longValue(), factory.create(bd2).getLong());
    }

    //------------------------------------------------------------< BOOLEAN >---
    /**
     * QValueImpl has a final static constant for the TRUE and the FALSE boolean
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.