https://blog.csdn.net/weixin_44259720/article/details/87002816
声明:
import java.math.BigInteger;
BigInteger n = new BigInteger(" ");
运算:
方法: m.方法(n);
运算类型:
加:add
减:subtract
乘:multiply
除:divide
取余:remainder,mod(//取模)
除数/取余:divideAndRemainder()[0/1] //0取除数,1取余数
平方:pow
绝对值:abs
相反数:negate
比较:
compareTo():返回int类型数据。 -1(小于),0(等于),1(大于)
max/min():返回大/小值,类型为BigInteger.
转换:
BigInteger.valueOf(int)
将int转换为BigInteger
注意:如果不要超过转换类型的定义范围。
** 转 int:**
1. int m = Integer.valueOf(n.toString());
2. int m = n.intValue();
注意:如果不要超过int的范围
转long:
long m = n.longValue();
转float
float m = n.floatValue():
转double
doube m = n.doubleValue():
转二进制补码
byte m = n.toByteArray();
转十进制字符串
String m = n.toString();
转radix制字符串
String m = n.toString(radix);