Get the smaller of two BigInteger values in CSharp
Description
The following code shows how to get the smaller of two BigInteger values.
Example
//from w ww .j av a2 s.com
using System;
using System.Numerics;
public class Example
{
public static void Main()
{
BigInteger[] numbers = { BigInteger.MinusOne, BigInteger.Pow(Int32.MaxValue, 2),BigInteger.Zero };
BigInteger smallest = numbers[numbers.GetLowerBound(0)];
for (int ctr = numbers.GetLowerBound(0) + 1; ctr <= numbers.GetUpperBound(0); ctr++)
smallest = BigInteger.Min(smallest, numbers[ctr]);
Console.WriteLine(smallest);
}
}
The code above generates the following result.