Examples of intValueExact()


Examples of java.math.BigDecimal.intValueExact()

        if (returnType.isAssignableFrom(BigDecimal.class)) {
          return returnType.cast(valueBigDecimal);
        } else if (returnType.isAssignableFrom(Long.class)) {
          return returnType.cast(valueBigDecimal.longValueExact());
        } else if (returnType.isAssignableFrom(Integer.class)) {
          return returnType.cast(valueBigDecimal.intValueExact());
        } else if (returnType.isAssignableFrom(Short.class)) {
          return returnType.cast(valueBigDecimal.shortValueExact());
        } else if (returnType.isAssignableFrom(Byte.class)) {
          return returnType.cast(valueBigDecimal.byteValueExact());
        } else {
View Full Code Here

Examples of java.math.BigDecimal.intValueExact()

     * The Java object is chosen such that .equals() works correctly across all Number-derived objects.
     */
    public static Number parseDecimal(String string) throws NumberFormatException {
        BigDecimal decimal=new BigDecimal(string);
        try {
            return decimal.intValueExact();
        }
        catch (ArithmeticException e) {
        }
        try {
            return decimal.longValueExact();
View Full Code Here

Examples of java.math.BigDecimal.intValueExact()

            }

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

                } 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.intValueExact()

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

                } 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.intValueExact()

  public static BigDecimal fun_POWER( BigDecimal _n, BigDecimal _p, MathContext _cx )
  {
    final BigDecimal pNormalized = _p.stripTrailingZeros();
    if (pNormalized.scale() <= 0) {
      final int p = pNormalized.intValueExact();
      if (p >= 0 && p <= 999999999) {
        return _n.pow( p, _cx );
      }
    }
    return valueOf( Math.pow( _n.doubleValue(), _p.doubleValue() ) );
View Full Code Here

Examples of java.math.BigDecimal.intValueExact()

    String a = "-123809648392384754573567356745735.63567890295784902768787678287E+21";
    BigDecimal aNumber = new BigDecimal(a);
    int result = 218520473;
    assertEquals("incorrect value", result, aNumber.intValue());
    try {
      aNumber.intValueExact();
      fail("Expected ArithmeticException on intValueExact");
    } catch (ArithmeticException expected) {
    }
  }
View Full Code Here

Examples of java.math.BigDecimal.intValueExact()

    String a = "123809648392384754573567356745735.63567890295784902768787678287E+21";
    BigDecimal aNumber = new BigDecimal(a);
    int result = -218520473;
    assertEquals("incorrect value", result, aNumber.intValue());
    try {
      aNumber.intValueExact();
      fail("Expected ArithmeticException on intValueExact");
    } catch (ArithmeticException expected) {
    }
  }
View Full Code Here

Examples of java.math.BigDecimal.intValueExact()

  /**
   * Test that constructing BigDecimals from zeros works properly.
   */
  public void testConstrZero() {
    BigDecimal bd = new BigDecimal("0");
    assertEquals(0, bd.intValueExact());
    assertEquals(1, bd.precision());
    assertEquals(0, bd.scale());
    bd = new BigDecimal("0.0");
    assertEquals(0, bd.intValueExact());
    assertEquals(1, bd.precision());
View Full Code Here

Examples of java.math.BigDecimal.intValueExact()

    BigDecimal bd = new BigDecimal("0");
    assertEquals(0, bd.intValueExact());
    assertEquals(1, bd.precision());
    assertEquals(0, bd.scale());
    bd = new BigDecimal("0.0");
    assertEquals(0, bd.intValueExact());
    assertEquals(1, bd.precision());
    assertEquals(1, bd.scale());
    bd = new BigDecimal("0.00");
    assertEquals(0, bd.intValueExact());
    assertEquals(1, bd.precision());
View Full Code Here

Examples of java.math.BigDecimal.intValueExact()

    bd = new BigDecimal("0.0");
    assertEquals(0, bd.intValueExact());
    assertEquals(1, bd.precision());
    assertEquals(1, bd.scale());
    bd = new BigDecimal("0.00");
    assertEquals(0, bd.intValueExact());
    assertEquals(1, bd.precision());
    assertEquals(2, bd.scale());
  }

  /**
 
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.