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.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var