Examples of divideAndRemainder()


Examples of java.math.BigInteger.divideAndRemainder()

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

Examples of java.math.BigInteger.divideAndRemainder()

    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

Examples of java.math.BigInteger.divideAndRemainder()

        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

Examples of java.math.BigInteger.divideAndRemainder()

          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

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

Examples of java.math.BigInteger.divideAndRemainder()

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

Examples of java.math.BigInteger.divideAndRemainder()

        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

Examples of java.math.BigInteger.divideAndRemainder()

        BigInteger[] quotAndRem;
       
        // while the number is even...
        while (!strippedBI.testBit(0)) {
            // To divide by 10^i
            quotAndRem = strippedBI.divideAndRemainder(TEN_POW[i]);
            // To look the remainder
            if (quotAndRem[1].signum() == 0) {
                // To adjust the scale
                newScale -= i;
                if (i < lastPow) {
View Full Code Here

Examples of java.math.BigInteger.divideAndRemainder()

    StringBuffer s = new StringBuffer ();
    BigInteger n = new BigInteger (1, b);
    while ( n.compareTo (BigInteger.ZERO) > 0 )
    {
      BigInteger[] r = n.divideAndRemainder (BigInteger.valueOf (58));
      n = r[0];
      char digit = b58[r[1].intValue ()];
      s.append (digit);
    }
    while ( lz > 0 )
View Full Code Here

Examples of java.math.BigInteger.divideAndRemainder()

        }

        StringBuffer s = new StringBuffer();
        BigInteger n = new BigInteger(1, b);
        while (n.compareTo(BigInteger.ZERO) > 0) {
            BigInteger[] r = n.divideAndRemainder(BigInteger.valueOf(58));
            n = r[0];
            char digit = b58[r[1].intValue()];
            s.append(digit);
        }
        while (lz > 0) {
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.