Java BigInteger 【 Java 大数常用用法 】

版权声明:转载请注明出处,谢谢。 https://blog.csdn.net/Mercury_Lc/article/details/89243123
package test;
import java.math.BigInteger;
import java.util.Scanner;
import javax.print.attribute.standard.OrientationRequested;
public class T {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger x,y;
		BigInteger bg[] = new BigInteger[555]; //开数组
		x = sc.nextBigInteger();
		y = sc.nextBigInteger();
		x = x.abs(); // x的绝对值
		x = x.add(y); // x加y
		x = x.and(y); // x和y按位与
		x = x.andNot(y); // x和y与非
		double xx = x.doubleValue(); // 将x返回double类型值
		float xxx = x.floatValue();
		int It = x.intValue();
		long Lg = x.longValue();
		BigInteger gcd = x.gcd(y); // x和y的最大公约数
		x = x.divide(y); // x除以y
		x = x.multiply(y); // x乘以y
		x = x.subtract(y);// x减y
		x = x.min(y);//  x与y取最小、大值
		x = x.max(y);
		x = x.mod(y); // x对y取模
		x = x.negate(); // 返回x的相反数
		BigInteger Notx = x.not();  //返回x的非
		BigInteger Or = x.or(y); //x和y按位或
		BigInteger Xor = x.xor(y);// x与y的异或
		int p = 33, n = 33;
		BigInteger Pow = x.pow(p); // x的p次方
		BigInteger Rem  = x.remainder(y); // x%y
		x = x.shiftLeft(n);// 将x左移n位后返回
		x = x.shiftRight(n);// 将x右移n位后返回
		byte[] TBA = x.toByteArray();//将x转换成二进制反码保存在byte数组中
		String sx = x.toString();// 将x转换成十进制的字符串形式
		System.out.println(x);
		
	}
}

猜你喜欢

转载自blog.csdn.net/Mercury_Lc/article/details/89243123