天天看點

java testbit 函數_Java.math.BigInteger類執行個體

java.math.BigInteger類提供操作類似所有Java的基本整數運算符和java.lang.Math中的所有相關的方法。

它還提供了模運算,GCD計算,素性測試,素數生成,位操作,和一些其他雜項業務操作。所有的操作行為,如果BigInteger的二進制補碼委托表示法。

算術運算和按位邏輯運算的語義分别類似于那些Java的整數算術運算符和Java的按位整數運算符。移位操作的語義擴充那些Java的移位運算符的允許負移的距離。

比較操作執行有符号整數的比較。提供子產品化的算術運算來計算殘留,執行幂運算和計算乘法逆。位運算操作對他們的操作數的二進制補碼表示的單個位。

在這個類将抛出NullPointerException,在所有方法和構造函數使用時,通過輸入任何參數提供一個空的對象引用。

類聲明

以下是java.math.BigInteger類的聲明:

publicclassBigIntegerextendsNumberimplementsComparable

字段域

以下是java.math.BigInteger類中的字段:

static BigInteger ONE -- BigInteger的常量1。

static BigInteger TEN -- BigInteger的常量10。

static BigInteger ZERO -- BigInteger的常量0。

類構造函數

S.N.

構造函數 & 描述

1

BigInteger(byte[] val)

這個構造函數用于轉換一個位元組數組包含BigInteger的二進制補碼,以二進制表示成一個BigInteger。

2

BigInteger(int signum, byte[] magnitude)

此構造函數用于将BigInteger的符号大小表示法轉換成一個BigInteger值。

3

BigInteger(int bitLength, int certainty, Random rnd)

此構造函數用于構造一個随機生成正BigInteger的可能是以指定的bitLength的素數。

4

BigInteger(int numBits, Random rnd)

此構造函數用于構造一個随機生成的BigInteger,均勻分布在範圍0到 (2numBits - 1), 包括.

5

BigInteger(String val)

此構造函數用于将BigInteger的十進制字元串表示形式轉換成一個BigInteger值。

6

BigInteger(String val, int radix)

這個構造函數用于轉換為BigInteger的指定基數為一個BigInteger的字元串表示形式。

類方法

S.N.

方法 & 描述

1

BigInteger abs()

此方法傳回一個BigInteger,其值是此BigInteger的絕對值。

2

BigInteger add(BigInteger val)

此方法傳回一個BigInteger,其值是(this + val).

3

BigInteger and(BigInteger val)

此方法傳回一個BigInteger,其值是 (this & val).

4

BigInteger andNot(BigInteger val)

此方法傳回一個BigInteger,其值是 (this & ~val).

5

int bitCount()

此方法傳回此BigInteger的二進制補碼表示的位,從符号位不同的數字。

6

int bitLength()

此方法傳回位在此BigInteger的最小的二進制補碼表示的數,不包括符号位。

7

BigInteger clearBit(int n)

此方法傳回一個BigInteger,其值相當于此BigInteger與指定位清零。

8

int compareTo(BigInteger val)

此方法比較此BigInteger與指定的BigInteger。

9

BigInteger divide(BigInteger val)

此方法傳回一個BigInteger,其值是 (this / val).

10

BigInteger[ ] divideAndRemainder(BigInteger val)

此方法傳回一個包含兩個BigIntegers:(this / val) 和 (this % val),其次是一個數組。

11

double doubleValue()

此方法此BigInteger轉換為雙精度double。

12

boolean equals(Object x)

此方法比較此BigInteger與指定對象是否相等。

13

BigInteger flipBit(int n)

此方法傳回一個BigInteger,其值相當于此BigInteger與指定位翻轉。

14

float floatValue()

此方法将BigInteger轉換為float。

15

BigInteger gcd(BigInteger val)

此方法傳回一個BigInteger,其值是絕對值的最大公約數:abs(this) 和abs(val)。

16

int getLowestSetBit()

此方法傳回最右邊的(最低階)的索引在此BigInteger1比特(零比特的數量,以最右側的1位的右側)。

17

int hashCode()

此方法傳回此BigInteger的哈希代碼。

18

int intValue()

此方法此BigInteger轉換為int。

19

boolean isProbablePrime(int certainty)

此方法傳回true,如果此BigInteger是素數,其絕對複合數則傳回false。

20

long longValue()

些方法将BigInteger轉換為long。

23

BigInteger mod(BigInteger m)

此方法傳回一個BigInteger,其值是(this mod m).

24

BigInteger modInverse(BigInteger m)

此方法傳回一個BigInteger,其值是 (this-1 mod m).

26

BigInteger multiply(BigInteger val)

此方法傳回一個BigInteger,其值是 (this * val).

27

BigInteger negate()

此方法傳回一個BigInteger,其值是 (-this).

28

29

BigInteger not()

此方法傳回一個BigInteger,其值是 (~this).

30

BigInteger or(BigInteger val)

此方法傳回一個BigInteger,其值是 (this | val).

31

BigInteger pow(int exponent)

此方法傳回一個BigInteger,其值是(thisexponent).

33

34

BigInteger setBit(int n)

此方法傳回一個BigInteger,其值相當于此BigInteger與指定的位設定。

35

BigInteger shiftLeft(int n)

此方法傳回一個BigInteger,其值是 (this << n).

36

BigInteger shiftRight(int n)

此方法傳回一個BigInteger,其值是 (this >> n).

37

int signum()

This method returns the signum function of this BigInteger.

38

BigInteger subtract(BigInteger val)

此方法傳回一個BigInteger,其值是 (this - val).

39

40

byte[ ] toByteArray()

此方法傳回一個包含此BigInteger的二進制補碼表示的位元組數組。

41

String toString()

此方法傳回此BigInteger的十進制字元串表示形式。

42

String toString(int radix)

此方法傳回在給定的基數以BigInteger的字元串表示形式。

44

BigInteger xor(BigInteger val)

此方法傳回一個BigInteger,其值是 (this ^ val).

¥ 我要打賞

糾錯/補充

收藏

加QQ群啦,易百教程官方技術學習群

注意:建議每個人選自己的技術方向加群,同一個QQ最多限加 3 個群。