|
JavaTM Platform Standard Ed. 6 |
|||||||||
앞의 클래스 다음의 클래스 | 프레임 있어 프레임 없음 | |||||||||
개요: 상자 | 필드 | 생성자 | 메소드 | 상세 : 필드 | 생성자 | 메소드 |
java.lang.Objectjava.lang.Number
java.math.BigInteger
public class BigInteger
변경이 불가능한, 임의 정밀도의 정수입니다. 모든 연산은, BigInteger 가 (Java 의 프리미티브(primitive) 정수형과 같은) 2 치 보수 표기법으로 나타내졌는지와 같이 동작합니다. BigInteger 는, Java 의 모든 프리미티브(primitive) 정수 연산자와 java.lang.Math 의 관련하는 모든 메소드에 동등의 것을 제공합니다. 또, BigInteger 는, 모듈러 산술, GCD 계산, 소수도 테스트, 소수 생성, 비트 조작, 그 외의 몇개의 조작에 대한 연산도 제공합니다.
산술 연산의 시멘틱스는, 「Java 언어 스펙」에 정의되고 있도록(듯이) Java 의 정수 산술 연산자를 정확하게 모방합니다. 예를 들어, 제로 제산은 ArithmeticException 를 throw 해, 정의 수에 의한 부의 수의 제산은 부 (또는 0)의 잉여를 냅니다. 오버플로우에 관한 스펙내의 자세한 것은 모두 무시되어 BigInteger 는 연산의 결과의 수락에 필요한 만큼 커집니다.
쉬프트 연산의 시멘틱스는, 부의 쉬프트 이동량을 가능하게 하기 위한(해) Java 의 쉬프트 연산자를 확장하고 있습니다. 부의 쉬프트 이동량을 가지는 오른쪽 쉬프트는 왼쪽 쉬프트가 됩니다. 역의 경우도 같습니다. 부호 없음의 오른쪽 쉬프트 연산자 (>>>)는, 이 연산에서는 이 클래스가 제공하는 「무한의 워드 사이즈」추출과 조합하는 의미가 거의 없기 때문에 생략해지고 있습니다.
비트 단위의 논리 연산의 시멘틱스는, Java 의 비트 정수 연산자의 시멘틱스를 정확하게 모방하고 있습니다. 2 항연산자 (and,or,xor)는, 연산전에 2 개의 오퍼랜드의 짧은 (분)편에 대해서 암묵적으로 부호 확장을 실시합니다.
비교 연산은 부호 첨부 정수의 비교를 실시합니다. 이것은, Java 의 관련하는 연산자 및 동등의 연산자에 의해 행해지는 것 것과 같습니다.
모듈러 산술 연산은, 잉여 계산, 나무승, 및 곱셈 역수 계산을 위해서(때문에) 제공되고 있습니다. 이러한 메소드는, 항상 0 으로 (modulus - 1) 의 사이의 부가 아닌 결과를 돌려줍니다.
비트 연산은, 오퍼랜드의 2 의 보수 표현의 싱글 비트에 사용합니다. 필요에 따라서, 오퍼랜드의 부호는 지시하는 비트를 가지도록(듯이) 확장됩니다. 연산중의 BigInteger 와 다른 부호를 가지는 BigInteger 를 생성하는 싱글 비트 연산은 없습니다. 이것은, 싱글 비트 연산이 단일의 비트에만 영향을 주어, 이 클래스가 제공하는 「무한의 워드 사이즈」추출에 의해, 각 BigInteger 에 선행하는 무한의 「가상 부호 비트」가 존재하기 (위해)때문에입니다.
설명을 알기 쉽고 간결하게 하기 위해서, BigInteger 메소드의 설명에서는 전체를 통해 의사 코드를 사용합니다. 의사 코드식 (i + j) 은, 「값이 BigInteger i 의 값과 BigInteger j 의 값의 화인 BigInteger」를 나타냅니다. 의사 코드식 (i == j) 은, 「BigInteger i 가 BigInteger j 와 같은 값을 나타내는 경우에만 true 인 것」을 나타냅니다. 다른 의사 코드식도 똑같이 해석됩니다.
이 클래스의 메소드 및 생성자 은 모두, 입력 파라메이타에 대해서 null 객체 참조가 건네받으면(자) NullPointerException
를 throw 합니다.
BigDecimal
,
직렬화 된 형식 필드의 개요 | |
---|---|
static BigInteger |
ONE
BigInteger 정수 1 입니다. |
static BigInteger |
TEN
BigInteger 정수 10 입니다. |
static BigInteger |
ZERO
BigInteger 정수 0 입니다. |
생성자 의 개요 | |
---|---|
BigInteger (byte[] val)
BigInteger 의 2 의 보수 2 진표현을 포함한 바이트 배열을 BigInteger 로 변환합니다. |
|
BigInteger (int signum,
byte[] magnitude)
BigInteger 의 부호 절대치 표현을 BigInteger 로 변환합니다. |
|
BigInteger (int bitLength,
int certainty,
Random rnd)
랜덤에 생성된 (아마 소수이다) 정의 BigInteger 를, 지정한 비트수로 구축합니다. |
|
BigInteger (int numBits,
Random rnd)
0 ~ (2numBits - 1) 의 범위에 한결같게 분산되고 있는, 랜덤에 생성된 BigInteger 를 구축합니다. |
|
BigInteger (String val)
BigInteger 의 10 진 String 표현을 BigInteger 로 변환합니다. |
|
BigInteger (String val,
int radix)
지정된 기수내의 BigInteger 의 String 표현을 BigInteger 로 변환합니다. |
메소드의 개요 | |
---|---|
BigInteger |
abs ()
값이 이 BigInteger 의 절대치인 BigInteger 를 돌려줍니다. |
BigInteger |
add (BigInteger val)
값이 (this + val) 인 BigInteger 를 돌려줍니다. |
BigInteger |
and (BigInteger val)
값이 (this & val) 의 BigInteger 를 돌려줍니다 (이 메소드는, this 와 val 의 양쪽 모두가 부의 경우는 부의 BigInteger 를 돌려준다). |
BigInteger |
andNot (BigInteger val)
값이 (this & ~val) 인 BigInteger 를 돌려줍니다. |
int |
bitCount ()
이 BigInteger 의 2 의 보수 표현내의, 부호 비트와 다른 비트의 수를 돌려줍니다. |
int |
bitLength ()
이 BigInteger 의 최소의 2 의 보수 표현내의 비트수를 돌려줍니다. |
BigInteger |
clearBit (int n)
값이 이 BigInteger 에 동일한 BigInteger 를, 지정된 비트를 클리어 해 돌려줍니다 ((this & ~(1<<n)) 를 계산한다). |
int |
compareTo (BigInteger val)
이 BigInteger 가 지정된 BigInteger 와 비교합니다. |
BigInteger |
divide (BigInteger val)
값이 (this / val) 인 BigInteger 를 돌려줍니다. |
BigInteger [] |
divideAndRemainder (BigInteger val)
(this / val) 그리고 (this % val) 계속되는, 2 개의 BigInteger 의 배열을 돌려줍니다. |
double |
doubleValue ()
이 BigInteger 를 double 로 변환합니다. |
boolean |
equals (Object x)
이 BigInteger 와 지정된 Object 가 동일한지 어떤지를 비교합니다. |
BigInteger |
flipBit (int n)
값이 이 BigInteger 에 동일한 BigInteger 를, 지정된 비트를 반전시켜 돌려줍니다 ((this ^ (1<<n)) 를 계산한다). |
float |
floatValue ()
이 BigInteger 를 float 로 변환합니다. |
BigInteger |
gcd (BigInteger val)
값이 abs(this) 와 abs(val) 의 최대공약수인 BigInteger 를 돌려줍니다. |
int |
getLowestSetBit ()
이 BigInteger 의 가장 우측 (1 번 낮은 위)의 1 비트의 인덱스 (가장 우측의 1 비트의 우측향의 0 비트의 수)를 돌려줍니다. |
int |
hashCode ()
이 BigInteger 의 해시 코드를 돌려줍니다. |
int |
intValue ()
이 BigInteger 를 int 로 변환합니다. |
boolean |
isProbablePrime (int certainty)
이 BigInteger 가 소수일 가능성이 높은 경우는 true, 반드시 합성수인 경우는 false 를 돌려줍니다. |
long |
longValue ()
이 BigInteger 를 long 로 변환합니다. |
BigInteger |
max (BigInteger val)
이 BigInteger 와 val 의 최대치를 돌려줍니다. |
BigInteger |
min (BigInteger val)
이 BigInteger 와 val 의 최소치를 돌려줍니다. |
BigInteger |
mod (BigInteger m)
값이 (this mod m)의 BigInteger 를 돌려줍니다. |
BigInteger |
modInverse (BigInteger m)
값이 (this-1 mod m) 의 BigInteger 를 돌려줍니다. |
BigInteger |
modPow (BigInteger exponent,
BigInteger m)
값이 (thisexponent mod m) 의 BigInteger 를 돌려줍니다 (pow 와 달리, 이 메소드는 부의 지수를 허용 한다). |
BigInteger |
multiply (BigInteger val)
값이 (this * val) 인 BigInteger 를 돌려줍니다. |
BigInteger |
negate ()
값이 (-this) 의 BigInteger 를 돌려줍니다. |
BigInteger |
nextProbablePrime ()
이 BigInteger 보다 큰 최초의 정수 (아마 소수)를 돌려줍니다. |
BigInteger |
not ()
값이 (~this) 의 BigInteger 를 돌려줍니다 (이 메소드는, 이 BigInteger 가 부가 아닌 경우에 0 보다 작은 값을 돌려준다). |
BigInteger |
or (BigInteger val)
값이 (this | val) 의 BigInteger 를 돌려줍니다 (이 메소드는, this 또는 val 가 부의 경우는 부의 BigInteger 를 돌려준다). |
BigInteger |
pow (int exponent)
값이 (thisexponent) 의 BigInteger 를 돌려줍니다. |
static BigInteger |
probablePrime (int bitLength,
Random rnd)
지정된 bit length로 정의 BigInteger (아마 소수)를 돌려줍니다. |
BigInteger |
remainder (BigInteger val)
값이 (this % val) 인 BigInteger 를 돌려줍니다. |
BigInteger |
setBit (int n)
값이 이 BigInteger 에 동일한 BigInteger 를, 지정된 비트를 설정해 돌려줍니다 ((this | (1<<n)) 를 계산한다). |
BigInteger |
shiftLeft (int n)
값이 (this << n) 의 BigInteger 를 돌려줍니다. |
BigInteger |
shiftRight (int n)
값이 (this >> n) 의 BigInteger 를 돌려줍니다. |
int |
signum ()
이 BigInteger 의 부호 요소를 돌려줍니다. |
BigInteger |
subtract (BigInteger val)
값이 (this - val) 인 BigInteger 를 돌려줍니다. |
boolean |
testBit (int n)
지정된 비트가 설정되어 있는 경우에만 true 를 돌려줍니다 ((this & (1<<n)) ! = 0) 을 계산한다). |
byte[] |
toByteArray ()
이 BigInteger 의 2 의 보수 표현을 포함한 바이트 배열을 돌려줍니다. |
String |
toString ()
이 BigInteger 의 10 진 String 표현을 돌려줍니다. |
String |
toString (int radix)
지정된 기수내의 이 BigInteger 의 String 표현을 돌려줍니다. |
static BigInteger |
valueOf (long val)
값이 지정된 long 의 값과 동일한 BigInteger 를 돌려줍니다. |
BigInteger |
xor (BigInteger val)
값이 (this ^ val) 의 BigInteger 를 돌려줍니다 (이 메소드는, this 와 val 의 다른 한쪽만이 부의 경우에 부의 BigInteger 를 돌려준다). |
클래스 java.lang. Number 로부터 상속된 메소드 |
---|
byteValue , shortValue |
클래스 java.lang. Object 로부터 상속된 메소드 |
---|
clone , finalize , getClass , notify , notifyAll , wait , wait , wait |
필드의 상세 |
---|
public static final BigInteger ZERO
public static final BigInteger ONE
public static final BigInteger TEN
생성자 의 상세 |
---|
public BigInteger(byte[] val)
val
- BigInteger 의, 빅 endian 2 의 보수 바이너리 표현
NumberFormatException
- val 의 길이가 0 바이트의 경우public BigInteger(int signum, byte[] magnitude)
signum
- 숫자의 부호 (부는 -1, 제로는 0,
정은 1)magnitude
- 숫자의 절대치의 빅 endian
바이너리 표현
NumberFormatException
- signum 가 3 개의 유효한 값 (-1, 0, 1)의 어떤 것도 아닌지,signum 가 0 으로,
magnitude 에 1 개 이상의 0 이외의 바이트가 포함되어 있는 경우public BigInteger(String val, int radix)
val
- BigInteger 의 String 표현radix
- val 의 해석으로 사용되는 기수
NumberFormatException
- val 가 지정한 기수내의
BigInteger 의 유효한 표현이 아닌지,radix 가
Character.MIN_RADIX
~ Character.MAX_RADIX
의
범위외에 있는 경우Character.digit(char, int)
public BigInteger(String val)
val
- BigInteger 의 10 진수의 String 표현
NumberFormatException
- val 는 BigInteger 의 표현으로서는 무효인Character.digit(char, int)
public BigInteger(int numBits, Random rnd)
numBits
- 새로운 BigInteger 의 최대 비트수rnd
- 새로운 BigInteger 의 계산으로 사용되는 랜덤 비트의 소스
IllegalArgumentException
- numBits 가 부의 경우bitLength
public BigInteger(int bitLength, int certainty, Random rnd)
확률을 지정할 필요가 없는 경우는, 이 생성자 은 아니고 probablePrime
메소드를 사용하는 것을 추천합니다.
bitLength
- 반환되는 BigInteger 의 bit lengthcertainty
- 호출측이 허용 하지 않는다
확률의 척도. 새로운 BigInteger 가
소수인 확률은,
(1 - 1/2certainty)보다 크다. 이 instructor의
실행 시간은 이 파라미터의 값 에 비례하는rnd
- 소수도를 테스트하는 후보의 선택으로 사용되는 랜덤 비트의 소스
ArithmeticException
- bitLength < 2bitLength
메소드의 상세 |
---|
public static BigInteger probablePrime(int bitLength, Random rnd)
bitLength
- 반환되는 BigInteger 의 bit lengthrnd
- 소수도를 테스트하는 후보의 선택으로 사용되는 랜덤 비트의 소스
ArithmeticException
- bitLength < 2bitLength
public BigInteger nextProbablePrime()
BigInteger
보다 큰 최초의 정수 (아마 소수)를 돌려줍니다. 이 메소드가 돌려주는 수가 합성수인 확률은 2-100 를 넘지 않습니다. 이 메소드는 검색시에 소수를 스킵 하지 않습니다. p 를 돌려주는 경우,this < q < p 가 성립되는 것 같은 소수 q 는 없습니다.
BigInteger
보다 큰 최초의 정수.
아마 소수
ArithmeticException
- this < 0public static BigInteger valueOf(long val)
long
의 값과 동일한 BigInteger 를 돌려줍니다. 이 「static 팩토리 메소드」는, 자주(잘) 사용되는 BigInteger 를 재사용할 수 있도록(듯이) 하기 위해서, (long
) 생성자 대신에 제공됩니다.
val
- 반환되는 BigInteger 의 값
public BigInteger add(BigInteger val)
val
- 이 BigInteger 에 가산하는 값
public BigInteger subtract(BigInteger val)
val
- 이 BigInteger 로부터 감산하는 값
public BigInteger multiply(BigInteger val)
val
- 이 BigInteger 로 곱셈하는 값
public BigInteger divide(BigInteger val)
val
- 이 BigInteger 를 제산하는 값
ArithmeticException
- val==0public BigInteger [] divideAndRemainder(BigInteger val)
val
- 이 BigInteger 를 제산하는 값, 및 계산된 잉여
ArithmeticException
- val==0public BigInteger remainder(BigInteger val)
val
- 이 BigInteger 를 제산하는 값, 및 계산된 잉여
ArithmeticException
- val==0public BigInteger pow(int exponent)
exponent
- 이 BigInteger 를 누승하는 지수
ArithmeticException
- exponent 가 부의 경우. (비정수치를 생성하는 연산이 생긴다. )public BigInteger gcd(BigInteger val)
val
- GCD 의 계산에 사용하는 값
public BigInteger abs()
public BigInteger negate()
public int signum()
public BigInteger mod(BigInteger m)
m
- 계수(modulus)
ArithmeticException
- m <= 0remainder(java.math.BigInteger)
public BigInteger modPow(BigInteger exponent, BigInteger m)
exponent
- 지수m
- 계수(modulus)
ArithmeticException
- m <= 0modInverse(java.math.BigInteger)
public BigInteger modInverse(BigInteger m)
m
- 계수(modulus)
ArithmeticException
- m <= 0 이든가, 혹은 이 BigInteger 가
mod m 의 곱셈 역수를 가지지 않는 경우 (즉, 이 BigInteger 가
m 의 「소수」가 아닌 경우)public BigInteger shiftLeft(int n)
n
- 비트 단위에서의 쉬프트 이동량
shiftRight(int)
public BigInteger shiftRight(int n)
n
- 비트 단위에서의 쉬프트 이동량
shiftLeft(int)
public BigInteger and(BigInteger val)
val
- 이 BigInteger 와의 논리츠무를 잡는 값
public BigInteger or(BigInteger val)
val
- 이 BigInteger 와의 논리합을 취하는 값
public BigInteger xor(BigInteger val)
val
- 이 BigInteger 와의 배타적 논리합을 취하는 값
public BigInteger not()
public BigInteger andNot(BigInteger val)
val
- 이 BigInteger 로 보수가 취해져 논리적이 취해지는 값
public boolean testBit(int n)
n
- 테스트하는 비트의 인덱스
ArithmeticException
- n 가 부의 경우public BigInteger setBit(int n)
n
- 설정하는 비트의 인덱스
ArithmeticException
- n 가 부의 경우public BigInteger clearBit(int n)
n
- 클리어 하는 비트의 인덱스
ArithmeticException
- n 가 부의 경우public BigInteger flipBit(int n)
n
- 반전하는 비트의 인덱스
ArithmeticException
- n 가 부의 경우public int getLowestSetBit()
public int bitLength()
public int bitCount()
public boolean isProbablePrime(int certainty)
certainty
- 호출측이 허용 하지 않는다
확률의 척도. 이 BigInteger 가 소수인 확률이
(1 - 1/2certainty) (을)를 넘는 경우는
true 를 돌려준다. 이 메소드의
실행 시간은 이 파라미터의 값 에 비례한다
public int compareTo(BigInteger val)
Comparable <BigInteger >
내의 compareTo
val
- 이 BigInteger 와 비교하는 BigInteger
public boolean equals(Object x)
Object
내의 equals
x
- 이 BigInteger 와 비교하는 Object
Object.hashCode()
,
Hashtable
public BigInteger min(BigInteger val)
val
- 최소치의 계산에 사용하는 값
public BigInteger max(BigInteger val)
val
- 최대치의 계산에 사용하는 값
public int hashCode()
Object
내의 hashCode
Object.equals(java.lang.Object)
,
Hashtable
public String toString(int radix)
Character.MIN_RADIX
~ Character.MAX_RADIX
의 범위외의 경우는, 디폴트를 10 으로 설정합니다 (Integer.toString 의 경우와 같다). Character.forDigit 에 의한 숫자로부터 문자에의 매핑이 사용되어 필요에 따라서 마이너스 부호를 전에 붙일 수 있는 (이 표현은 (String, int
)
생성자 과 호환성이 있다).
radix
- String 표현의 기수
Integer.toString(int, int)
,
Character.forDigit(int, int)
,
BigInteger(java.lang.String, int)
public String toString()
(String)
생성자 과 호환성이 있어, Java 의 + 연산자와의 연결을 가능하게 한다).
Object
내의 toString
Character.forDigit(int, int)
,
BigInteger(java.lang.String)
public byte[] toByteArray()
(byte[])
생성자 과 호환성이 있다).
BigInteger(byte[])
public int intValue()
int
로 변환합니다. 이 변환은,「Java 언어 스펙」으로 정의된 long
로부터 int
에의 「네로우 프리미티브(primitive) 변환」이라고 같습니다. 이 BigInteger 가 너무 길어 int
내에 들어가지 않는 경우, 하위 32 비트만이 돌려주어집니다. 이 변환에 의해, 이 BigInteger 치의 절대치 전체에 관한 정보가 없어져 역의 부호로 돌려주어질 가능성이 있습니다.
Number
내의 intValue
int
에 변환된 이 BigIntegerpublic long longValue()
long
로 변환합니다. 이 변환은,「Java 언어 스펙」으로 정의된 long
로부터 int
에의 「네로우 프리미티브(primitive) 변환」이라고 같습니다. 이 BigInteger 가 너무 길어 long
내에 들어가지 않는 경우, 하위 64 비트만이 돌려주어집니다. 이 변환에 의해, 이 BigInteger 치의 절대치 전체에 관한 정보가 없어져 역의 부호로 돌려주어질 가능성이 있습니다.
Number
내의 longValue
long
에 변환된 이 BigIntegerpublic float floatValue()
float
로 변환합니다. 이 변환은,「Java 언어 스펙」으로 정의된 double
로부터 float
에의 「네로우 프리미티브(primitive) 변환」이라고 같습니다. 이 BigInteger 가 너무 커 float
로서 표현할 수 없는 경우, 적당 Float.NEGATIVE_INFINITY
또는 Float.POSITIVE_INFINITY
에 변환됩니다. 반환값이 유한한 경우도, 이 변환에 의해, BigInteger 치의 정밀도에 관한 정보가 없어질 가능성이 있습니다.
Number
내의 floatValue
float
에 변환된 이 BigIntegerpublic double doubleValue()
double
로 변환합니다. 이 변환은,「Java 언어 스펙」으로 정의된 double
로부터 float
에의 「네로우 프리미티브(primitive) 변환」이라고 같습니다. 이 BigInteger 가 너무 커 double
로서 표현할 수 없는 경우, 적당 Double.NEGATIVE_INFINITY
또는 Double.POSITIVE_INFINITY
에 변환됩니다. 반환값이 유한한 경우도, 이 변환에 의해, BigInteger 치의 정밀도에 관한 정보가 없어질 가능성이 있습니다.
Number
내의 doubleValue
double
에 변환된 이 BigInteger
|
JavaTM Platform Standard Ed. 6 |
|||||||||
앞의 클래스 다음의 클래스 | 프레임 있어 프레임 없음 | |||||||||
개요: 상자 | 필드 | 생성자 | 메소드 | 상세 : 필드 | 생성자 | 메소드 |
Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy 도 참조해 주세요.