728x90
BigInteger 클래스
BigInteger 클래스는 long의 범위를 넘는 엄청 큰 정수를 다루며, java.math 패키지에 포함되어 있다.
메서드를 통해 사칙연산 등을 할 수 있으며, 사칙연산의 대상또한 BigInteger이어야 한다.
StringBuffer 클래스 생성자
BigInteger(Byte[]) | BigInteger의 두 개의 보수 이진 표현을 포함하는 바이트 배열을 BigInteger로 변환합니다. |
BigInteger(Btye[], int32, int32) | BigInteger의 두 개의 보수 이진 표현을 포함하는 바이트 하위 배열을 BigInteger로 변환합니다. |
BigInteger(int32, Byte[]) | BigInteger의 부호 크기 표현을 BigInteger로 변환합니다. |
BigInteger(int32, Byte[], int32, int32) | BigInteger의 부호 크기 표현을 BigInteger로 변환합니다. |
BigInteger(int32, int32, Random) | 지정된 bitLength를 사용하여 소수일 수 있는 임의로 생성된 양의 BigInteger를 생성합니다. |
BigInteger(int32, Random) | 임의로 생성된 BigInteger를 생성하며, 범위 0에서 (2<sup<>numBits/sup> - 1)까지 균일하게 분산됩니다. |
BigInteger(intPtr, JniHandle Ownership) | JNI 개체의 관리형 표현을 만들 때 사용되는 생성자입니다. 런타임에서 호출합니다. |
BigInteger(String) | BigInteger의 10진수 문자열 표현을 BigInteger로 변환합니다. |
BigInteger(String, int32) | 지정된 radix에서 BigInteger의 String 표현을 BigInteger로 변환합니다. |
생성 예)
BigInteger a = new BigInteger(br.readLine());
728x90
BigInteger 속성
Class | 이 Object의 런타임 클래스를 반환합니다. |
Handle | 기본 Android instance 대한 핸들입니다. |
JnildentityHashCode | 변경할 수 없는 임의 정밀도 정수입니다. |
JniPeerMembers | 변경할 수 없는 임의 정밀도 정수입니다. |
LowestSetBit | 이 BigInteger에서 가장 오른쪽(가장 낮은 순서) 1비트의 인덱스를 반환합니다(맨 오른쪽 1비트 오른쪽에 있는 0비트 수). |
One | BigInteger 상수 1입니다. |
PeerReference | 변경할 수 없는 임의 정밀도 정수입니다. |
Ten | BigInteger 상수 10. |
ThresholdClass | 이 API는 Android용 Mono 인프라를 지원하며 코드에서 직접 사용할 수 없습니다. |
ThresholdType | 이 API는 Android용 Mono 인프라를 지원하며 코드에서 직접 사용할 수 없습니다. |
Two | BigInteger 상수 2입니다. |
Zero | BigInteger 상수 0입니다. |
사용 예)
BigInteger Two=BigInteger.TWO;
BigInteger 메소드
자주 사용되는 메소드들을 위주로 정리하였다. 더 자세히 알고 싶다면 여기 참고(https://learn.microsoft.com/ko-kr/dotnet/api/java.math.biginteger?view=net-android-34.0)
BigInteger 클래스 (Java.Math)
변경할 수 없는 임의 정밀도 정수입니다.
learn.microsoft.com
Abs() | 이 BigInteger의 절대값인 BigInteger를 반환합니다. |
Add(BigInteger) | 값이 (this + val)인 BigInteger를 반환합니다. |
Clone() | 이 개체의 복사본을 만들고 반환합니다. |
CompareTo(BigInteger) | 이 BigInteger와 지정된 BigInteger를 비교합니다. |
Divede(BigInteger) | 값이 (this / val) 인 BigInteger를 반환합니다. |
DivedeAndRemainder(BigInteger) | 뒤에 (this % val)가 포함된 두 BigIntegers의 (this / val) 배열을 반환합니다. |
Equals(Object) | 다른 개체가 이 개체와 "같음"인지 여부를 나타냅니다. |
IntValue() | 이 BigInteger를 int로 변환합니다. |
LongValue() | 이 BigInteger를 long로 변환합니다. |
Max(BigInteger) | 이 BigInteger 및 val의 최대값을 반환합니다. |
Min(BigInteger) | 이 BigInteger 및 val의 최소값을 반환합니다. |
Mod(BigInteger) | 값 (this mod m)인 BigInteger를 반환합니다. |
Multiply(BigInteger) | 값이 (this * val)인 BigInteger를 반환합니다. |
Negate() | 값이 (-this)인 BigInteger를 반환합니다. |
Remainder(BigInteger) | 값이 (this % val)인 BigInteger를 반환합니다. |
Sqrt() | 이 BigInteger의 정수 제곱근을 반환합니다. |
SqrtAndRemainder() | 의 정수 제곱근 s 과 나머지 this - s*s를 각각 포함하는 두 BigIntegers의 this 배열을 반환합니다. |
Subtract(BigInteger) | 값이 (this - val)인 BigInteger를 반환합니다. |
ToString() | 개체의 문자열 표현을 반환합니다. |
사용 예)
https://gamzaggang7.tistory.com/85
[백준 자바] 22193번(Multiply) | BigInteger 클래스 사용하기
난이도 - 브론즈 5 문제 Write a program that computes a product of two non-negative integers A and B. The integers are represented in decimal notation and have N and M digits, respectively. 입력 The first line contains the lengths N and M, separat
gamzaggang7.tistory.com
728x90
'Java' 카테고리의 다른 글
[Java] 2차원 배열을 특정 열 기준으로 정렬하기 (0) | 2024.05.22 |
---|---|
[Java] ArrayList로 2차원 배열 표현 및 정렬 (Collections) (1) | 2024.04.19 |
[Java] StringBuffer 클래스란? (0) | 2024.03.03 |
[Java] 자바의 기본 타입 (논리/문자/정수/실수) 메모리 공간, 데이터 값 범의 (0) | 2024.03.03 |
[JUnit] 인텔리제이 IDEA에 JUnit 설정 (1) | 2023.09.28 |