BigInteger.Equals Method (Int64)
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Returns a value that indicates whether the current instance and a signed 64-bit integer have the same value.
Namespace: System.Numerics
Assembly: System.Numerics (in System.Numerics.dll)
Syntax
'Declaration
Public Function Equals ( _
other As Long _
) As Boolean
public bool Equals(
long other
)
Parameters
- other
Type: System.Int64
The signed 64-bit integer value to compare.
Return Value
Type: System.Boolean
true if the signed 64-bit integer and the current instance have the same value; otherwise, false.
Remarks
If other is a Byte, Int16, Int32, SByte, UInt16, or UInt32 value, it is implicitly converted to an Int64 value when the method is called.
To determine the relationship between the two objects instead of just testing for equality, call the BigInteger.CompareTo(Int64) method.
Examples
The following example instantiates a BigInteger object from each integral type except UInt64. It then calls the Equals(Int64) method to compare the BigInteger value with the original integer value that was passed to the BigInteger constructor. As the output shows, the values are equal in each case.
Dim bigIntValue As BigInteger
Dim byteValue As Byte = 16
bigIntValue = New BigInteger(byteValue)
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
byteValue.GetType().Name, byteValue,
bigIntValue.Equals(byteValue)) + vbCrLf
Dim sbyteValue As SByte = -16
bigIntValue = New BigInteger(sbyteValue)
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
sbyteValue.GetType().Name, sbyteValue,
bigIntValue.Equals(sbyteValue)) + vbCrLf
Dim shortValue As Short = 1233
bigIntValue = New BigInteger(shortValue)
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
shortValue.GetType().Name, shortValue,
bigIntValue.Equals(shortValue)) + vbCrLf
Dim ushortValue As UShort = 64000
bigIntValue = New BigInteger(ushortValue)
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
ushortValue.GetType().Name, ushortValue,
bigIntValue.Equals(ushortValue)) + vbCrLf
Dim intValue As Integer = -1603854
bigIntValue = New BigInteger(intValue)
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
intValue.GetType().Name, intValue,
bigIntValue.Equals(intValue)) + vbCrLf
Dim uintValue As UInteger = 1223300
bigIntValue = New BigInteger(uintValue)
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
uintValue.GetType().Name, uintValue,
bigIntValue.Equals(uintValue)) + vbCrLf
Dim longValue As Long = -123822229012
bigIntValue = New BigInteger(longValue)
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
longValue.GetType().Name, longValue,
bigIntValue.Equals(longValue)) + vbCrLf
' 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
BigInteger bigIntValue;
byte byteValue = 16;
bigIntValue = new BigInteger(byteValue);
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
byteValue.GetType().Name, byteValue,
bigIntValue.Equals(byteValue)) + "\n";
sbyte sbyteValue = -16;
bigIntValue = new BigInteger(sbyteValue);
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
sbyteValue.GetType().Name, sbyteValue,
bigIntValue.Equals(sbyteValue)) + "\n";
short shortValue = 1233;
bigIntValue = new BigInteger(shortValue);
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
shortValue.GetType().Name, shortValue,
bigIntValue.Equals(shortValue)) + "\n";
ushort ushortValue = 64000;
bigIntValue = new BigInteger(ushortValue);
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
ushortValue.GetType().Name, ushortValue,
bigIntValue.Equals(ushortValue)) + "\n";
int intValue = -1603854;
bigIntValue = new BigInteger(intValue);
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
intValue.GetType().Name, intValue,
bigIntValue.Equals(intValue)) + "\n";
uint uintValue = 1223300;
bigIntValue = new BigInteger(uintValue);
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
uintValue.GetType().Name, uintValue,
bigIntValue.Equals(uintValue)) + "\n";
long longValue = -123822229012;
bigIntValue = new BigInteger(longValue);
outputBlock.Text += String.Format("{0} {1} = {2} {3} : {4}",
bigIntValue.GetType().Name, bigIntValue,
longValue.GetType().Name, longValue,
bigIntValue.Equals(longValue)) + "\n";
// 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
Version Information
Silverlight
Supported in: 5, 4
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.