Examples of longValueExact()


Examples of java.math.BigDecimal.longValueExact()

      try {
        final BigDecimal valueBigDecimal = new BigDecimal(valueString);
        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)) {
View Full Code Here

Examples of java.math.BigDecimal.longValueExact()

            return decimal.intValueExact();
        }
        catch (ArithmeticException e) {
        }
        try {
            return decimal.longValueExact();
        }
        catch (ArithmeticException e) {
        }
        try {
            return decimal.toBigIntegerExact();
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()

      return dividedBy(new BigDecimal(divisor), roundingMode);
    }

    @Override public ShortDuration dividedBy(BigDecimal divisor, RoundingMode roundingMode) {
      BigDecimal product = BigDecimal.valueOf(picos).divide(divisor, roundingMode);
      return ofPicos(product.longValueExact());
    }

    @Override public int compareTo(ShortDuration that) {
      return Longs.compare(this.picos, that.picos);
    }
View Full Code Here

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()

    String a = "-123809648392384754573567356745735.63567890295784902768787678287E+21";
    BigDecimal aNumber = new BigDecimal(a);
    long result = -1246043477766677607L;
    assertTrue("incorrect value", aNumber.longValue() == result);
    try {
      aNumber.longValueExact();
      fail("Expected ArithmeticException on longValueExact");
    } catch (ArithmeticException expected) {
    }
  }
View Full Code Here

Examples of java.math.BigDecimal.longValueExact()

    String a = "123809648392384754573567356745735.63567890295784902768787678287E+21";
    BigDecimal aNumber = new BigDecimal(a);
    long result = 1246043477766677607L;
    assertTrue("incorrect value", aNumber.longValue() == result);
    try {
      aNumber.longValueExact();
      fail("Expected ArithmeticException on longValueExact");
    } catch (ArithmeticException expected) {
    }
  }
View Full Code Here

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()

                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()

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