JAVA 的BigInteger

import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String args[]) {
		Scanner cin = new Scanner(System.in);
		// 读到EOF
		while (cin.hasNext()) {
		}
		// 读入BigInteger
		BigInteger a = cin.nextBigInteger();

		// 构造方法
		// 将十进制字符串转化为BigInteger
		// public BigInteger(String val)
		BigInteger b = new BigInteger("3");
		// byte范围-128到+127 8为2进制数 c为767(1011111111)
		// public BigInteger(byte[] val)
		byte[] bt = new byte[] { 2, -1 };
		BigInteger c = new BigInteger(bt);
		// 将radix进制的字符串转化为BigInteger
		// public BigInteger(String val, int radix)
		BigInteger d = new BigInteger("3", 2);
		// 随机生成 0到2的numBits次方 -1的随机数
		// public BigInteger(int numBits, Random rnd)
		BigInteger e = new BigInteger(10, new Random());
		// signum为符号位 1为正 0为0 -1为负
		// public BigInteger(int signum, byte[] magnitude)
		BigInteger f = new BigInteger(-1, bt);
		// 随机生成一个 长度为bitLength的 可能性大于(1-1/(2的certainty次方))是素数 的数
		// public BigInteger(int bitLength, int certainty, Random rnd)
		BigInteger g = new BigInteger(10, 1, new Random());

		// 常量
		// 0
		// public static final BigInteger ZERO
		a = BigInteger.ZERO;
		// 1
		// public static final BigInteger ONE
		a = BigInteger.ONE;
		// 10
		// public static final BigInteger TEN
		a = BigInteger.TEN;

		// 静态方法
		// 随机生成一个 长度为bitLength的可能是素数的数
		// public static BigInteger probablePrime(int bitLength, Random rnd)
		BigInteger.probablePrime(10, new Random());
		// 值等于val的值
		// public static BigInteger valueOf(long val)
		BigInteger.valueOf(10);

		// 加法a+b
		// public BigInteger add(BigInteger val)
		a.add(b);
		// 减法a-b
		// public BigInteger subtract(BigInteger val)
		a.subtract(b);
		// 乘法a*b
		// public BigInteger subtract(BigInteger val)
		a.multiply(b);
		// 除法a/b
		// public BigInteger divide(BigInteger val)
		a.divide(b);
		// 取模a%b b需大于0 5mod3=2 -5mod3=1
		// public BigInteger mod(BigInteger m)
		a.mod(b);
		// 求余 5rem3=2 -5rem3=-2 5rem-3=2 -5rem-3=-2
		// public BigInteger remainder(BigInteger val)
		a.remainder(b);
		// [0]为a/b [1]为a%b
		// public BigInteger[] divideAndRemainder(BigInteger val)
		a.divideAndRemainder(b);

		// a==b?
		// public boolean equals(Object x)
		a.equals(b);
		// a的正负 正为1 0为0 负为-1
		// public int signum()
		a.signum();
		// 绝对值|a|
		// public BigInteger abs()
		a.abs();
		// 比较a>b返回1 a==b返回0 a> n)
		// public BigInteger shiftRight(int n)
		a.shiftRight(10);
		// a&(~b)
		// public BigInteger andNot(BigInteger val)
		a.andNot(b);
		// 二进制形式中把第n位二进制设为0 (a & ~(1< getClass()
		a.getClass();
		// public final void notify()
		a.notify();
		// public final void notifyAll()
		a.notifyAll();
		try {
			// public final void wait() throws InterruptedException
			a.wait();
			// public final void wait(long timeout) throws InterruptedException
			a.wait(10);
			// public final void wait(long timeout, int nanos) throws InterruptedException
			a.wait(10, 10);
		} catch (Exception exception) {
		}
	}
}

 

你可能感兴趣的:(Java基础)