C# BigInteger Min

Description

BigInteger Min Returns the smaller of two BigInteger values.

Syntax

BigInteger.Min has the following syntax.


public static BigInteger Min(
  BigInteger left,
  BigInteger right
)

Parameters

BigInteger.Min has the following parameters.

  • left - The first value to compare.
  • right - The second value to compare.

Returns

BigInteger.Min method returns The left or right parameter, whichever is smaller.

Example


using System;//  ww w . ja  v  a  2  s .  co m
using System.Numerics;

public class Example
{
   public static void Main()
   {
      BigInteger[] numbers = { Int64.MaxValue * BigInteger.MinusOne, 
                               BigInteger.MinusOne, 
                               BigInteger.Add(BigInteger.Pow(Int64.MaxValue, 2), 
                                              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("   {0:N0}", smallest);
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Numerics »




BigInteger
Complex