BigInteger a = new BigInteger("1234567890") ; //声明 BigInteger b = new BigInteger("123456") ; a = str.valueOf(); //从string str中取值 a = BigInteger(str, 10);// 将str转化为十进制得BigInteger型 a = Bigteger.ONE; //赋初值(几个常量) a = Bigteger.ZERO; a = Bigteger.TEN;
a.add(b); //a+b a.subtract(b); //a-b a.multiply(b); //a*b a.divide(b); //a/b a.max(b); //max(a,b); a.min(b); //min(a,b); a.negate(); //a*(-1); a.remainder(b); //a%b (得正余数) a.mod(b); //a%b (余数符号同a) BigInteger str[] = a.divideAndRemainder(b); //str[0] = a/b && str[1] = a%b a.pow(b); //a^b a.gcd(b); //最大公约数 a.abs(); //取绝对值 a.shiftLeft; // << 左移 a.shiftRight; // >> 右移 and // && or // || xor // ^ not // ! int n = a.intValue(); //转化为int型 long n = a.longValue(); float n = a.floatValue(); double n = a.doublue(); a.compareTo(b); //比较大小 a<b return -1, a>b return 1, a==b return 0 a.equals(b); //比较是否相等 a==b return true, a!=b return false a.isProbablePrime(int certainty) //如果该 BigInteger 可能是素数,则返回 true ;如果它很明确是一个合数,则返回 false //certainty - 这一措施的调用者能容忍的不确定性: //如果调用返回true,则此BigInteger是素数超过概率(1 - 1/2确定性)。 //此方法的执行时间正比于该参数的值。 change("3", 10, 2); //将十进制的3转为二进制数 String str = new BigInteger("20", 10).toString(16); //将十进制的20转为十六进制数