Examples of divideAndRemainder()


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

     * @return a {@code Duration}, not null
     * @throws ArithmeticException if numeric overflow occurs
     */
    private static Duration create(BigDecimal seconds) {
        BigInteger nanos = seconds.movePointRight(9).toBigIntegerExact();
        BigInteger[] divRem = nanos.divideAndRemainder(BI_NANOS_PER_SECOND);
        if (divRem[0].bitLength() > 63) {
            throw new ArithmeticException("Exceeds capacity of Duration: " + nanos);
        }
        return ofSeconds(divRem[0].longValue(), divRem[1].intValue());
    }
View Full Code Here

Examples of java.math.BigInteger.divideAndRemainder()

        if (multiplicand == 1) {
            return this;
        }
        BigInteger nanos = toNanosBigInteger();
        nanos = nanos.multiply(BigInteger.valueOf(multiplicand));
        BigInteger[] divRem = nanos.divideAndRemainder(BILLION);
        if (divRem[0].bitLength() > 63) {
            throw new ArithmeticException("Multiplication result exceeds capacity of Duration: " + this + " * " + multiplicand);
        }
        return seconds(divRem[0].longValue(), divRem[1].intValue());
     }
View Full Code Here

Examples of java.math.BigInteger.divideAndRemainder()

        if (divisor == 1) {
            return this;
        }
        BigInteger nanos = toNanosBigInteger();
        nanos = nanos.divide(BigInteger.valueOf(divisor));
        BigInteger[] divRem = nanos.divideAndRemainder(BILLION);
        return seconds(divRem[0].longValue(), divRem[1].intValue());
     }

    //-----------------------------------------------------------------------
    /**
 
View Full Code Here

Examples of java.math.BigInteger.divideAndRemainder()

      }
      else if( Type.BIG_DECIMAL.equals( t ) ) {
        final BigDecimal d = (BigDecimal) n;
        int shift = 0;
        BigInteger unscaled = d.unscaledValue();       
        BigInteger[] dandr = unscaled.divideAndRemainder( BigInteger.TEN );
        while( BigInteger.ZERO.equals( dandr[1] ) ) {
          unscaled = dandr[0];
          shift--;
          dandr = unscaled.divideAndRemainder( BigInteger.TEN );
        }
View Full Code Here

Examples of java.math.BigInteger.divideAndRemainder()

        BigInteger unscaled = d.unscaledValue();       
        BigInteger[] dandr = unscaled.divideAndRemainder( BigInteger.TEN );
        while( BigInteger.ZERO.equals( dandr[1] ) ) {
          unscaled = dandr[0];
          shift--;
          dandr = unscaled.divideAndRemainder( BigInteger.TEN );
        }
        return (shift == 0)
          ? d
          : d.setScale( d.scale() + shift );
      }
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
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.