Get the larger of two BigInteger values in CSharp

Description

The following code shows how to get the larger of two BigInteger values.

Example


  //  ww w.j  ava2  s. c o  m
  
  
  

using System;
using System.Numerics;

public class Example
{
    public static void Main()
   {
      BigInteger[] numbers = { BigInteger.MinusOne, BigInteger.Pow(Int32.MaxValue, 2) };
      BigInteger largest = numbers[numbers.GetLowerBound(0)];

      for (int ctr = numbers.GetLowerBound(0) + 1; ctr <= numbers.GetUpperBound(0); ctr++)
         largest = BigInteger.Max(largest, numbers[ctr]);

      Console.WriteLine(largest);
   }
}

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