Package java.math

Examples of java.math.BigInteger.divideAndRemainder()


            }
            /* mlo/S = maximum acceptable error, divided by 10^k, if the output is less than d. */
            /* mhi/S = maximum acceptable error, divided by 10^k, if the output is greater than d. */

            for(i = 1;;i++) {
                BigInteger[] divResult = b.divideAndRemainder(S);
                b = divResult[1];
                dig = (char)(divResult[0].intValue() + '0');
                /* Do we yet have the shortest decimal string
                 * that will round to d?
                 */
 
View Full Code Here


            }
        }
        else
            for(i = 1;; i++) {
//                (char)(dig = quorem(b,S) + '0');
                BigInteger[] divResult = b.divideAndRemainder(S);
                b = divResult[1];
                dig = (char)(divResult[0].intValue() + '0');
                buf.append(dig);
                if (i >= ilim)
                    break;
View Full Code Here

                        /*
                         * System.out.println("jpb time " + time);
                         */
                        if (time != 0) {
                                String fStr = "";
                                BigInteger[] H = t.divideAndRemainder(hours);
                                BigInteger[] M = H[1].divideAndRemainder(minutes);
                                BigInteger[] S = M[1].divideAndRemainder(seconds);
                                if (H[0].intValue() > 0) {
                                        fStr += String.format("%1$2d:", H[0].intValue());
                                }
View Full Code Here

    // start [to fill] at the little end of the [bigendian] output
    int i = out0.length - 1;

    int fractionSize1 = fractionSize;
    while (fractionSize1 >= 64) {
      final BigInteger[] divrem = mantissa.divideAndRemainder(BIG_INTEGER_TWO_POWER_64);
      // [according to BigInteger javadoc] this takes the least significant 64 bits;
      // i.e. in this case the long is considered unsigned, as we want it
      out0[i] = divrem[1].longValue();

      fractionSize1 -= 64;
View Full Code Here

    static BigInteger findIntegerRoot(BigInteger base, BigInteger power) {
        BigInteger maxBits = BigInteger.valueOf(base.bitLength() + 1); // base < 2 ^ (maxBits + 1)
        // => base ^ ( 1 / power ) < 2 ^ ( (maxBits + 1) / power )

        BigInteger[] divResult = maxBits.divideAndRemainder(power);
        if (divResult[1].signum() == 0) // i.e. divResult[1] == 0
            maxBits = divResult[0];
        else
            maxBits = divResult[0].add(BigInteger.ONE);
View Full Code Here

        int scale = value.scale();
        if (scale > 0) {
            BigInteger i = value.unscaledValue();
            while (true) {
                BigInteger[] dr = i.divideAndRemainder(BIG_INTEGER_TEN);
                if (dr[1].equals(BigInteger.ZERO)) {
                    i = dr[0];
                    scale--;
                    if (scale==0) {
                        break;
View Full Code Here

          int scale = value.scale();
          if (scale > 0) {
              BigInteger i = value.unscaledValue();
              while (true) {
                  final BigInteger[] dr = i.divideAndRemainder(BIG_INTEGER_TEN);
                  if (dr[1].equals(BigInteger.ZERO)) {
                      i = dr[0];
                      scale--;
                      if (scale==0) {
                          break;
View Full Code Here

            }
            /* mlo/S = maximum acceptable error, divided by 10^k, if the output is less than d. */
            /* mhi/S = maximum acceptable error, divided by 10^k, if the output is greater than d. */

            for(i = 1;;i++) {
                BigInteger[] divResult = b.divideAndRemainder(S);
                b = divResult[1];
                dig = (char)(divResult[0].intValue() + '0');
                /* Do we yet have the shortest decimal string
                 * that will round to d?
                 */
 
View Full Code Here

            }
        }
        else
            for(i = 1;; i++) {
//                (char)(dig = quorem(b,S) + '0');
                BigInteger[] divResult = b.divideAndRemainder(S);
                b = divResult[1];
                dig = (char)(divResult[0].intValue() + '0');
                buf.append(dig);
                if (i >= ilim)
                    break;
View Full Code Here

        HarmonyBigDecimal integralValue = new HarmonyBigDecimal(quotAndRem[0]);
        long resultPrecision = integralValue.precision();
        int i = 1;
        // To strip trailing zeros until the specified precision is reached
        while (!strippedBI.testBit(0)) {
            quotAndRem = strippedBI.divideAndRemainder(TEN_POW[i]);
            if ((quotAndRem[1].signum() == 0) &&
                    ((resultPrecision - i >= mcPrecision)
                    || (newScale - i >= diffScale)) ) {
                resultPrecision -= i;
                newScale -= i;
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.