Package java.math

Examples of java.math.BigDecimal.toBigInteger()


  public void testToBigIntegerPos2() {
    String a = "123809648392384754573567356745735.63567890295784902768787678287E+15";
    BigInteger bNumber = new BigInteger(
        "123809648392384754573567356745735635678902957849");
    BigDecimal aNumber = new BigDecimal(a);
    BigInteger result = aNumber.toBigInteger();
    assertTrue("incorrect value", result.equals(bNumber));
  }

  /**
   * Convert a positive BigDecimal to BigInteger.
View Full Code Here


  public void testToBigIntegerPos3() {
    String a = "123809648392384754573567356745735.63567890295784902768787678287E+45";
    BigInteger bNumber = new BigInteger(
        "123809648392384754573567356745735635678902957849027687876782870000000000000000");
    BigDecimal aNumber = new BigDecimal(a);
    BigInteger result = aNumber.toBigInteger();
    assertTrue("incorrect value", result.equals(bNumber));
  }

  /**
   * Convert a small BigDecimal to BigInteger.
View Full Code Here

   */
  public void testToBigIntegerZero() {
    String a = "-123809648392384754573567356745735.63567890295784902768787678287E-500";
    BigInteger bNumber = new BigInteger("0");
    BigDecimal aNumber = new BigDecimal(a);
    BigInteger result = aNumber.toBigInteger();
    assertTrue("incorrect value", result.equals(bNumber));
  }

  /**
   * Convert a negative BigDecimal to an engineering string representation.
View Full Code Here

            if (ctx.configuration().dialect() == SQLDialect.SQLITE) {
                result = Convert.convert(ctx.resultSet().getString(ctx.index()), (Class<T>) BigInteger.class);
            }
            else {
                BigDecimal b = ctx.resultSet().getBigDecimal(ctx.index());
                result = (T) (b == null ? null : b.toBigInteger());
            }
        }
        else if (type == BigDecimal.class) {
            // The SQLite JDBC driver doesn't support BigDecimals
            if (ctx.configuration().dialect() == SQLDialect.SQLITE) {
View Full Code Here

        else if (type == Boolean.class) {
            result = (T) wasNull(ctx.statement(), Boolean.valueOf(ctx.statement().getBoolean(ctx.index())));
        }
        else if (type == BigInteger.class) {
            BigDecimal d = ctx.statement().getBigDecimal(ctx.index());
            result = (T) (d == null ? null : d.toBigInteger());
        }
        else if (type == BigDecimal.class) {
            result = (T) ctx.statement().getBigDecimal(ctx.index());
        }
        else if (type == Byte.class) {
View Full Code Here

        else if (type == Boolean.class) {
            result = (T) wasNull(ctx.input(), Boolean.valueOf(ctx.input().readBoolean()));
        }
        else if (type == BigInteger.class) {
            BigDecimal d = ctx.input().readBigDecimal();
            result = (T) (d == null ? null : d.toBigInteger());
        }
        else if (type == BigDecimal.class) {
            result = (T) ctx.input().readBigDecimal();
        }
        else if (type == Byte.class) {
View Full Code Here

     */
    public void testToBigIntegerPos1() {
        String a = "123809648392384754573567356745735.63567890295784902768787678287E+21";
        BigInteger bNumber = new BigInteger("123809648392384754573567356745735635678902957849027687");
        BigDecimal aNumber = new BigDecimal(a);
        BigInteger result = aNumber.toBigInteger();
        assertTrue("incorrect value", result.equals(bNumber));
    }

    /**
     * Convert a positive BigDecimal to BigInteger
View Full Code Here

     */
    public void testToBigIntegerPos2() {
        String a = "123809648392384754573567356745735.63567890295784902768787678287E+15";
        BigInteger bNumber = new BigInteger("123809648392384754573567356745735635678902957849");
        BigDecimal aNumber = new BigDecimal(a);
        BigInteger result = aNumber.toBigInteger();
        assertTrue("incorrect value", result.equals(bNumber));
    }

    /**
     * Convert a positive BigDecimal to BigInteger
View Full Code Here

     */
    public void testToBigIntegerPos3() {
        String a = "123809648392384754573567356745735.63567890295784902768787678287E+45";
        BigInteger bNumber = new BigInteger("123809648392384754573567356745735635678902957849027687876782870000000000000000");
        BigDecimal aNumber = new BigDecimal(a);
        BigInteger result = aNumber.toBigInteger();
        assertTrue("incorrect value", result.equals(bNumber));
    }

    /**
     * Convert a negative BigDecimal to BigInteger
View Full Code Here

     */
    public void testToBigIntegerNeg1() {
        String a = "-123809648392384754573567356745735.63567890295784902768787678287E+21";
        BigInteger bNumber = new BigInteger("-123809648392384754573567356745735635678902957849027687");
        BigDecimal aNumber = new BigDecimal(a);
        BigInteger result = aNumber.toBigInteger();
        assertTrue("incorrect value", result.equals(bNumber));
    }

    /**
     * Convert a negative BigDecimal to BigInteger
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.