BigInteger.Equals 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
두 개의 숫자 값이 같은지를 나타내는 값을 반환합니다.
오버로드
Equals(UInt64) |
현재 인스턴스와 부호 없는 64비트 정수의 값이 같은지를 나타내는 값을 반환합니다. |
Equals(Object) |
현재 인스턴스와 지정된 개체의 값이 같은지를 나타내는 값을 반환합니다. |
Equals(BigInteger) |
현재 인스턴스와 지정된 BigInteger 개체의 값이 같은지 여부를 나타내는 값을 반환합니다. |
Equals(Int64) |
현재 인스턴스와 부호 있는 64비트 정수의 값이 같은지를 나타내는 값을 반환합니다. |
Equals(UInt64)
- Source:
- BigInteger.cs
- Source:
- BigInteger.cs
- Source:
- BigInteger.cs
중요
이 API는 CLS 규격이 아닙니다.
현재 인스턴스와 부호 없는 64비트 정수의 값이 같은지를 나타내는 값을 반환합니다.
public:
bool Equals(System::UInt64 other);
[System.CLSCompliant(false)]
public bool Equals (ulong other);
[<System.CLSCompliant(false)>]
override this.Equals : uint64 -> bool
Public Function Equals (other As ULong) As Boolean
매개 변수
- other
- UInt64
비교할 부호 없는 64비트 정수입니다.
반환
현재 인스턴스와 부호 없는 64비트 정수의 값이 같으면 true
이고, 그렇지 않으면 false
입니다.
- 특성
예제
다음 예제에서는 지구에서 여러 별의 대략적인 거리를 지구에서 엡실론 인디의 거리와 비교하여 같은지 여부를 확인합니다. 이 예제에서는 메서드의 각 오버로드를 Equals 사용하여 같음을 테스트합니다.
#using <System.Numerics.dll>
using namespace System;
using namespace System::Numerics;
void main()
{
const Int64 LIGHT_YEAR = 5878625373183;
BigInteger altairDistance = 17 * LIGHT_YEAR;
BigInteger epsilonIndiDistance = 12 * LIGHT_YEAR;
BigInteger ursaeMajoris47Distance = 46 * LIGHT_YEAR;
Int64 tauCetiDistance = 12 * LIGHT_YEAR;
UInt64 procyon2Distance = 12 * LIGHT_YEAR;
Object^ wolf424ABDistance = 14 * LIGHT_YEAR;
Console::WriteLine("Approx. equal distances from Epsilon Indi to:");
Console::WriteLine(" Altair: {0}",
epsilonIndiDistance.Equals(altairDistance));
Console::WriteLine(" Ursae Majoris 47: {0}",
epsilonIndiDistance.Equals(ursaeMajoris47Distance));
Console::WriteLine(" TauCeti: {0}",
epsilonIndiDistance.Equals(tauCetiDistance));
Console::WriteLine(" Procyon 2: {0}",
epsilonIndiDistance.Equals(procyon2Distance));
Console::WriteLine(" Wolf 424 AB: {0}",
epsilonIndiDistance.Equals(wolf424ABDistance));
}
/*
The example displays output like the following:
Approx. equal distances from Epsilon Indi to:
Altair: False
Ursae Majoris 47: False
TauCeti: True
Procyon 2: True
Wolf 424 AB: False
*/
const long LIGHT_YEAR = 5878625373183;
BigInteger altairDistance = 17 * LIGHT_YEAR;
BigInteger epsilonIndiDistance = 12 * LIGHT_YEAR;
BigInteger ursaeMajoris47Distance = 46 * LIGHT_YEAR;
long tauCetiDistance = 12 * LIGHT_YEAR;
ulong procyon2Distance = 12 * LIGHT_YEAR;
object wolf424ABDistance = 14 * LIGHT_YEAR;
Console.WriteLine("Approx. equal distances from Epsilon Indi to:");
Console.WriteLine(" Altair: {0}",
epsilonIndiDistance.Equals(altairDistance));
Console.WriteLine(" Ursae Majoris 47: {0}",
epsilonIndiDistance.Equals(ursaeMajoris47Distance));
Console.WriteLine(" TauCeti: {0}",
epsilonIndiDistance.Equals(tauCetiDistance));
Console.WriteLine(" Procyon 2: {0}",
epsilonIndiDistance.Equals(procyon2Distance));
Console.WriteLine(" Wolf 424 AB: {0}",
epsilonIndiDistance.Equals(wolf424ABDistance));
// The example displays the following output:
// Approx. equal distances from Epsilon Indi to:
// Altair: False
// Ursae Majoris 47: False
// TauCeti: True
// Procyon 2: True
// Wolf 424 AB: False
Const LIGHT_YEAR As Long = 5878625373183
Dim altairDistance As BigInteger = 17 * LIGHT_YEAR
Dim epsilonIndiDistance As BigInteger = 12 * LIGHT_YEAR
Dim ursaeMajoris47Distance As BigInteger = 46 * LIGHT_YEAR
Dim tauCetiDistance As BigInteger = 12 * LIGHT_YEAR
Dim procyon2Distance As Long = 12 * LIGHT_YEAR
Dim wolf424ABDistance As Object = 14 * LIGHT_YEAR
Console.WriteLine("Approx. equal distances from Epsilon Indi to:")
Console.WriteLine(" Altair: {0}", _
epsilonIndiDistance.Equals(altairDistance))
Console.WriteLine(" Ursae Majoris 47: {0}", _
epsilonIndiDistance.Equals(ursaeMajoris47Distance))
Console.WriteLine(" TauCeti: {0}", _
epsilonIndiDistance.Equals(tauCetiDistance))
Console.WriteLine(" Procyon 2: {0}", _
epsilonIndiDistance.Equals(procyon2Distance))
Console.WriteLine(" Wolf 424 AB: {0}", _
epsilonIndiDistance.Equals(wolf424ABDistance))
' The example displays the following output:
' Approx. equal distances from Epsilon Indi to:
' Altair: False
' Ursae Majoris 47: False
' TauCeti: True
' Procyon 2: True
' Wolf 424 AB: False
설명
같음을 테스트하는 대신 두 개체 간의 관계를 확인하려면 메서드를 호출합니다 BigInteger.CompareTo(UInt64) .
적용 대상
Equals(Object)
- Source:
- BigInteger.cs
- Source:
- BigInteger.cs
- Source:
- BigInteger.cs
현재 인스턴스와 지정된 개체의 값이 같은지를 나타내는 값을 반환합니다.
public:
override bool Equals(System::Object ^ obj);
public override bool Equals (object obj);
public override bool Equals (object? obj);
override this.Equals : obj -> bool
Public Overrides Function Equals (obj As Object) As Boolean
매개 변수
- obj
- Object
비교할 개체입니다.
반환
obj
인수가 BigInteger 개체이고 값이 현재 BigInteger 인스턴스의 값과 같으면 true
이고, 그렇지 않으면 false
입니다.
예제
다음 예제에서는 병렬 Object 및 BigInteger 배열을 정의합니다. 한 배열의 각 요소는 두 번째 배열의 해당 요소와 동일한 값을 가합니다. 예제의 출력에서 알 수 있듯이 배열의 instance BigInteger 후자가 BigInteger 이고 해당 값이 같은 경우에만 배열의 Object instance 동일한 것으로 간주됩니다.
using System;
using System.Numerics;
public class Example
{
public static void Main()
{
object[] obj = { 0, 10, 100, new BigInteger(1000), -10 };
BigInteger[] bi = { BigInteger.Zero, new BigInteger(10),
new BigInteger(100), new BigInteger(1000),
new BigInteger(-10) };
for (int ctr = 0; ctr < bi.Length; ctr++)
Console.WriteLine(bi[ctr].Equals(obj[ctr]));
}
}
// The example displays the following output:
// False
// False
// False
// True
// False
Imports System.Numerics
Module Example
Public Sub Main()
Dim obj() As object = { 0, 10, 100, New BigInteger(1000), -10 }
Dim bi() As BigInteger = { BigInteger.Zero, New BigInteger(10),
New BigInteger(100), New BigInteger(1000),
New BigInteger(-10) }
For ctr As Integer = 0 To bi.Length - 1
Console.WriteLine(bi(ctr).Equals(obj(ctr)))
Next
End Sub
End Module
' The example displays the following output:
' False
' False
' False
' True
' False
설명
인수가 obj
값이 BigInteger 아니면 메서드는 를 반환합니다 false
. 메서드는 값이 BigInteger 현재 instance 같은 instance 경우에만 obj
를 반환 true
합니다.
같음을 테스트하는 대신 두 개체 간의 관계를 확인하려면 메서드를 호출합니다 CompareTo(Object) .
적용 대상
Equals(BigInteger)
- Source:
- BigInteger.cs
- Source:
- BigInteger.cs
- Source:
- BigInteger.cs
현재 인스턴스와 지정된 BigInteger 개체의 값이 같은지 여부를 나타내는 값을 반환합니다.
public:
virtual bool Equals(System::Numerics::BigInteger other);
public bool Equals (System.Numerics.BigInteger other);
override this.Equals : System.Numerics.BigInteger -> bool
Public Function Equals (other As BigInteger) As Boolean
매개 변수
- other
- BigInteger
비교할 개체입니다.
반환
이 BigInteger 개체와 other
의 값이 같으면 true
이고, 그렇지 않으면 false
입니다.
구현
예제
다음 예제에서는 지구에서 여러 별의 대략적인 거리를 지구에서 엡실론 인디의 거리와 비교하여 같은지 여부를 확인합니다. 이 예제에서는 메서드의 각 오버로드를 Equals 사용하여 같음을 테스트합니다.
#using <System.Numerics.dll>
using namespace System;
using namespace System::Numerics;
void main()
{
const Int64 LIGHT_YEAR = 5878625373183;
BigInteger altairDistance = 17 * LIGHT_YEAR;
BigInteger epsilonIndiDistance = 12 * LIGHT_YEAR;
BigInteger ursaeMajoris47Distance = 46 * LIGHT_YEAR;
Int64 tauCetiDistance = 12 * LIGHT_YEAR;
UInt64 procyon2Distance = 12 * LIGHT_YEAR;
Object^ wolf424ABDistance = 14 * LIGHT_YEAR;
Console::WriteLine("Approx. equal distances from Epsilon Indi to:");
Console::WriteLine(" Altair: {0}",
epsilonIndiDistance.Equals(altairDistance));
Console::WriteLine(" Ursae Majoris 47: {0}",
epsilonIndiDistance.Equals(ursaeMajoris47Distance));
Console::WriteLine(" TauCeti: {0}",
epsilonIndiDistance.Equals(tauCetiDistance));
Console::WriteLine(" Procyon 2: {0}",
epsilonIndiDistance.Equals(procyon2Distance));
Console::WriteLine(" Wolf 424 AB: {0}",
epsilonIndiDistance.Equals(wolf424ABDistance));
}
/*
The example displays output like the following:
Approx. equal distances from Epsilon Indi to:
Altair: False
Ursae Majoris 47: False
TauCeti: True
Procyon 2: True
Wolf 424 AB: False
*/
const long LIGHT_YEAR = 5878625373183;
BigInteger altairDistance = 17 * LIGHT_YEAR;
BigInteger epsilonIndiDistance = 12 * LIGHT_YEAR;
BigInteger ursaeMajoris47Distance = 46 * LIGHT_YEAR;
long tauCetiDistance = 12 * LIGHT_YEAR;
ulong procyon2Distance = 12 * LIGHT_YEAR;
object wolf424ABDistance = 14 * LIGHT_YEAR;
Console.WriteLine("Approx. equal distances from Epsilon Indi to:");
Console.WriteLine(" Altair: {0}",
epsilonIndiDistance.Equals(altairDistance));
Console.WriteLine(" Ursae Majoris 47: {0}",
epsilonIndiDistance.Equals(ursaeMajoris47Distance));
Console.WriteLine(" TauCeti: {0}",
epsilonIndiDistance.Equals(tauCetiDistance));
Console.WriteLine(" Procyon 2: {0}",
epsilonIndiDistance.Equals(procyon2Distance));
Console.WriteLine(" Wolf 424 AB: {0}",
epsilonIndiDistance.Equals(wolf424ABDistance));
// The example displays the following output:
// Approx. equal distances from Epsilon Indi to:
// Altair: False
// Ursae Majoris 47: False
// TauCeti: True
// Procyon 2: True
// Wolf 424 AB: False
Const LIGHT_YEAR As Long = 5878625373183
Dim altairDistance As BigInteger = 17 * LIGHT_YEAR
Dim epsilonIndiDistance As BigInteger = 12 * LIGHT_YEAR
Dim ursaeMajoris47Distance As BigInteger = 46 * LIGHT_YEAR
Dim tauCetiDistance As BigInteger = 12 * LIGHT_YEAR
Dim procyon2Distance As Long = 12 * LIGHT_YEAR
Dim wolf424ABDistance As Object = 14 * LIGHT_YEAR
Console.WriteLine("Approx. equal distances from Epsilon Indi to:")
Console.WriteLine(" Altair: {0}", _
epsilonIndiDistance.Equals(altairDistance))
Console.WriteLine(" Ursae Majoris 47: {0}", _
epsilonIndiDistance.Equals(ursaeMajoris47Distance))
Console.WriteLine(" TauCeti: {0}", _
epsilonIndiDistance.Equals(tauCetiDistance))
Console.WriteLine(" Procyon 2: {0}", _
epsilonIndiDistance.Equals(procyon2Distance))
Console.WriteLine(" Wolf 424 AB: {0}", _
epsilonIndiDistance.Equals(wolf424ABDistance))
' The example displays the following output:
' Approx. equal distances from Epsilon Indi to:
' Altair: False
' Ursae Majoris 47: False
' TauCeti: True
' Procyon 2: True
' Wolf 424 AB: False
설명
이 메서드는 인터페이스를 IEquatable<T> 구현하고 매개 변수 BigInteger 를 개체로 변환 other
할 필요가 없기 때문에 보다 Equals(Object) 약간 더 잘 수행됩니다.
같음을 테스트하는 대신 두 BigInteger 개체 간의 관계를 확인하려면 메서드를 호출합니다 BigInteger.CompareTo(BigInteger) .
적용 대상
Equals(Int64)
- Source:
- BigInteger.cs
- Source:
- BigInteger.cs
- Source:
- BigInteger.cs
현재 인스턴스와 부호 있는 64비트 정수의 값이 같은지를 나타내는 값을 반환합니다.
public:
bool Equals(long other);
public bool Equals (long other);
override this.Equals : int64 -> bool
Public Function Equals (other As Long) As Boolean
매개 변수
- other
- Int64
비교할 부호 있는 64비트 정수 값입니다.
반환
부호 있는 64비트 정수와 현재 인스턴스의 값이 같으면 true
이고, 그렇지 않으면 false
입니다.
예제
다음 예제에서는 를 제외한 UInt64각 정수 형식에서 개체를 인스턴스화 BigInteger 합니다. 그런 다음 메서드를 Equals(Int64) 호출하여 값을 생성자에 전달된 BigInteger 원래 정수 값과 비교 BigInteger 합니다. 출력에서와 같이 값은 각 경우에 동일합니다.
#using <System.Numerics.dll>
using namespace System;
using namespace System::Numerics;
void main()
{
BigInteger bigIntValue;
Byte byteValue = 16;
bigIntValue = BigInteger(byteValue);
Console::WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType()->Name, bigIntValue,
byteValue.GetType()->Name, byteValue,
bigIntValue.Equals((Int64)byteValue));
SByte sbyteValue = -16;
bigIntValue = BigInteger(sbyteValue);
Console::WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType()->Name, bigIntValue,
sbyteValue.GetType()->Name, sbyteValue,
bigIntValue.Equals((Int64)sbyteValue));
Int16 shortValue = 1233;
bigIntValue = BigInteger(shortValue);
Console::WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType()->Name, bigIntValue,
shortValue.GetType()->Name, shortValue,
bigIntValue.Equals((Int64)shortValue));
UInt16 ushortValue = 64000;
bigIntValue = BigInteger(ushortValue);
Console::WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType()->Name, bigIntValue,
ushortValue.GetType()->Name, ushortValue,
bigIntValue.Equals((Int64)ushortValue));
int intValue = -1603854;
bigIntValue = BigInteger(intValue);
Console::WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType()->Name, bigIntValue,
intValue.GetType()->Name, intValue,
bigIntValue.Equals((Int64)intValue));
UInt32 uintValue = 1223300;
bigIntValue = BigInteger(uintValue);
Console::WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType()->Name, bigIntValue,
uintValue.GetType()->Name, uintValue,
bigIntValue.Equals((Int64)uintValue));
Int64 longValue = -123822229012;
bigIntValue = BigInteger(longValue);
Console::WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType()->Name, bigIntValue,
longValue.GetType()->Name, longValue,
bigIntValue.Equals((Int64)longValue));
}
/*
The example displays output like the following:
BigInteger 16 = Byte 16 : True
BigInteger -16 = SByte -16 : True
BigInteger 1233 = Int16 1233 : True
BigInteger 64000 = UInt16 64000 : True
BigInteger -1603854 = Int32 -1603854 : True
BigInteger 1223300 = UInt32 1223300 : True
BigInteger -123822229012 = Int64 -123822229012 : True
*/
BigInteger bigIntValue;
byte byteValue = 16;
bigIntValue = new BigInteger(byteValue);
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
byteValue.GetType().Name, byteValue,
bigIntValue.Equals(byteValue));
sbyte sbyteValue = -16;
bigIntValue = new BigInteger(sbyteValue);
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
sbyteValue.GetType().Name, sbyteValue,
bigIntValue.Equals(sbyteValue));
short shortValue = 1233;
bigIntValue = new BigInteger(shortValue);
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
shortValue.GetType().Name, shortValue,
bigIntValue.Equals(shortValue));
ushort ushortValue = 64000;
bigIntValue = new BigInteger(ushortValue);
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
ushortValue.GetType().Name, ushortValue,
bigIntValue.Equals(ushortValue));
int intValue = -1603854;
bigIntValue = new BigInteger(intValue);
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
intValue.GetType().Name, intValue,
bigIntValue.Equals(intValue));
uint uintValue = 1223300;
bigIntValue = new BigInteger(uintValue);
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
uintValue.GetType().Name, uintValue,
bigIntValue.Equals(uintValue));
long longValue = -123822229012;
bigIntValue = new BigInteger(longValue);
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
longValue.GetType().Name, longValue,
bigIntValue.Equals(longValue));
// The example displays the following output:
// BigInteger 16 = Byte 16 : True
// BigInteger -16 = SByte -16 : True
// BigInteger 1233 = Int16 1233 : True
// BigInteger 64000 = UInt16 64000 : True
// BigInteger -1603854 = Int32 -1603854 : True
// BigInteger 1223300 = UInt32 1223300 : True
// BigInteger -123822229012 = Int64 -123822229012 : True
Dim bigIntValue As BigInteger
Dim byteValue As Byte = 16
bigIntValue = New BigInteger(byteValue)
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
byteValue.GetType().Name, byteValue,
bigIntValue.Equals(byteValue))
Dim sbyteValue As SByte = -16
bigIntValue = New BigInteger(sbyteValue)
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
sbyteValue.GetType().Name, sbyteValue,
bigIntValue.Equals(sbyteValue))
Dim shortValue As Short = 1233
bigIntValue = New BigInteger(shortValue)
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
shortValue.GetType().Name, shortValue,
bigIntValue.Equals(shortValue))
Dim ushortValue As UShort = 64000
bigIntValue = New BigInteger(ushortValue)
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
ushortValue.GetType().Name, ushortValue,
bigIntValue.Equals(ushortValue))
Dim intValue As Integer = -1603854
bigIntValue = New BigInteger(intValue)
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
intValue.GetType().Name, intValue,
bigIntValue.Equals(intValue))
Dim uintValue As UInteger = 1223300
bigIntValue = New BigInteger(uintValue)
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
uintValue.GetType().Name, uintValue,
bigIntValue.Equals(uintValue))
Dim longValue As Long = -123822229012
bigIntValue = New BigInteger(longValue)
Console.WriteLine("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
longValue.GetType().Name, longValue,
bigIntValue.Equals(longValue))
' The example displays the following output:
' BigInteger 16 = Byte 16 : True
' BigInteger -16 = SByte -16 : True
' BigInteger 1233 = Int16 1233 : True
' BigInteger 64000 = UInt16 64000 : True
' BigInteger -1603854 = Int32 -1603854 : True
' BigInteger 1223300 = UInt32 1223300 : True
' BigInteger -123822229012 = Int64 -123822229012 : True
설명
가 Byte, , Int16, Int32, UInt16SByte또는 UInt32 값이면 other
메서드가 호출되면 암시적으로 값으로 변환 Int64 됩니다.
같음을 테스트하는 대신 두 개체 간의 관계를 확인하려면 메서드를 호출합니다 BigInteger.CompareTo(Int64) .
적용 대상
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기