C# BigInteger CompareTo(UInt64)
Description
BigInteger CompareTo(UInt64)
Compares this instance
to an unsigned 64-bit integer and returns an integer that indicates whether
the value of this instance is less than, equal to, or greater than the value
of the unsigned 64-bit integer.
Syntax
BigInteger.CompareTo(UInt64)
has the following syntax.
[CLSCompliantAttribute(false)]
public int CompareTo(
ulong other
)
Parameters
BigInteger.CompareTo(UInt64)
has the following parameters.
other
- The unsigned 64-bit integer to compare.
Returns
BigInteger.CompareTo(UInt64)
method returns A signed integer that indicates the relative value of this instance and other,
as shown in the following table. Return value Description Less than zero
The current instance is less than other. Zero The current instance equals
other. Greater than zero The current instance is greater than other.
Example
/*from w w w .jav a 2 s .c o m*/
using System;
using System.IO;
using System.Numerics;
public class Example
{
public static void Main()
{
BigInteger bigIntValue = BigInteger.Parse("12312312312312312312");
byte byteValue = 16;
sbyte sbyteValue = -16;
short shortValue = 1233;
ushort ushortValue = 1233;
int intValue = -12233;
uint uintValue = 12233;
long longValue = 12382222;
ulong ulongValue = 1238222;
Console.WriteLine("Comparing {0} with {1}: {2}",
bigIntValue, byteValue,
bigIntValue.CompareTo(byteValue));
Console.WriteLine("Comparing {0} with {1}: {2}",
bigIntValue, sbyteValue,
bigIntValue.CompareTo(sbyteValue));
Console.WriteLine("Comparing {0} with {1}: {2}",
bigIntValue, shortValue,
bigIntValue.CompareTo(shortValue));
Console.WriteLine("Comparing {0} with {1}: {2}",
bigIntValue, ushortValue,
bigIntValue.CompareTo(ushortValue));
Console.WriteLine("Comparing {0} with {1}: {2}",
bigIntValue, intValue,
bigIntValue.CompareTo(intValue));
Console.WriteLine("Comparing {0} with {1}: {2}",
bigIntValue, uintValue,
bigIntValue.CompareTo(uintValue));
Console.WriteLine("Comparing {0} with {1}: {2}",
bigIntValue, longValue,
bigIntValue.CompareTo(longValue));
Console.WriteLine("Comparing {0} with {1}: {2}",
bigIntValue, ulongValue,
bigIntValue.CompareTo(ulongValue));
}
}
The code above generates the following result.