java.math.BigInteger.divideAndRemainder(BigInteger val)%uA0返回包含两个BigIntegers的(this / val) ,其次(this % val) 的数组。%uA0
声明
以下是java.math.BigInteger.divideAndRemainder()方法的声明
public BigInteger[] divideAndRemainder(BigInteger val)
参数
-
val%uA0- 由此BigInteger是进行除法运算(除数),并计算的余数
返回值
此方法返回2个BigIntegers的数组:商值(this / val) 是初始元素,剩余部分%uA0(this % val)%uA0是最后一个元素。
异常
-
ArithmeticException%uA0- 如果val是0
例子
下面的例子显示math.BigInteger.divideAndRemainder()方法的用法
package com.yiibai import java.math.* public class BigIntegerDemo { public static void main(String[] args) { // create 2 BigInteger objects BigInteger bi1, bi2 bi1 = new BigInteger("-100") bi2 = new BigInteger("3") // BigInteger array bi stores result of bi1/bi2 BigInteger bi[] = bi1.divideAndRemainder(bi2) // print quotient and remainder System.out.println("Division result") System.out.println("Quotient is " + bi[0] ) System.out.println("Remainder is " + bi[1] ) } }
让我们编译和运行上面的程序,这将产生以下结果:
Division result Quotient is -33 Remainder is -1