首页上一页 1 下一页尾页 1 条记录 1/1页
请教BigInteger
发表在Java图书答疑
2010-03-30
是否精华
是
否
版块置顶:
是
否
public BigInteger[] divideAndRemainder(BigInteger val)方法如何使用,能否给写个小例子。
书中:例9.10
package com.wsy;
import java.math.BigInteger;
public class BigIntegerDemo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
BigInteger r=new BigInteger("98765432100000");
System.out.println(r.add(new BigInteger("1000000000000")));
System.out.println(r.subtract(new BigInteger("1000000000000")));
System.out.println(r.multiply(new BigInteger("1000000000000")));
System.out.println(r.divide(new BigInteger("1000000000000")));
System.out.println(r.remainder(new BigInteger("1000000000000")));
[font color=#FF0000]System.out.println(r.divideAndRemainder(new BigInteger("1000000000000")));
[/font]System.out.println(r.pow(2));
System.out.println(r.negate());
}
}
返回值:
[font color=]99765432100000
97765432100000
98765432100000000000000000
98
765432100000
[font color=#FF0000][Ljava.math.BigInteger;@c17164
[/font]9754610577899710410000000000
-98765432100000[/font]
出现这个[Ljava.math.BigInteger;@c17164是什么意思,系统也不报错。
书中:例9.10
package com.wsy;
import java.math.BigInteger;
public class BigIntegerDemo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
BigInteger r=new BigInteger("98765432100000");
System.out.println(r.add(new BigInteger("1000000000000")));
System.out.println(r.subtract(new BigInteger("1000000000000")));
System.out.println(r.multiply(new BigInteger("1000000000000")));
System.out.println(r.divide(new BigInteger("1000000000000")));
System.out.println(r.remainder(new BigInteger("1000000000000")));
[font color=#FF0000]System.out.println(r.divideAndRemainder(new BigInteger("1000000000000")));
[/font]System.out.println(r.pow(2));
System.out.println(r.negate());
}
}
返回值:
[font color=]99765432100000
97765432100000
98765432100000000000000000
98
765432100000
[font color=#FF0000][Ljava.math.BigInteger;@c17164
[/font]9754610577899710410000000000
-98765432100000[/font]
出现这个[Ljava.math.BigInteger;@c17164是什么意思,系统也不报错。