BigInteger.Min Method

Silverlight

Returns the smaller of two BigInteger values.

Namespace:  System.Numerics
Assembly:  System.Numerics (in System.Numerics.dll)

Syntax

```public static BigInteger Min(
BigInteger left,
BigInteger right
)
```

Parameters

left
Type: System.Numerics.BigInteger
The first value to compare.
right
Type: System.Numerics.BigInteger
The second value to compare.

Return Value

Type: System.Numerics.BigInteger
The left or right parameter, whichever is smaller.

Remarks

This method corresponds to the Math.Min method for primitive numeric types.

Examples

The following example uses the Min method to select the smallest number in an array of BigInteger values.

```
using System;
using System.Numerics;

public class Example
{
public static void Demo(System.Windows.Controls.TextBlock outputBlock)
{
outputBlock.FontFamily = new System.Windows.Media.FontFamily("Courier New");
BigInteger[] numbers = { Int64.MaxValue * BigInteger.MinusOne,
BigInteger.MinusOne,
10359321239000,
BigInteger.Pow(103988, 2),
BigInteger.Multiply(Int32.MaxValue, Int16.MaxValue),
BigInteger.Pow(Int32.MaxValue, 2)),
BigInteger.Zero };
if (numbers.Length < 2)
{
outputBlock.Text += String.Format("Cannot determine which is the smaller of {0} numbers.",
numbers.Length) + "\n";
return;
}

BigInteger smallest = numbers[numbers.GetLowerBound(0)];

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

outputBlock.Text += "The values:" + "\n";
foreach (BigInteger number in numbers)
outputBlock.Text += String.Format("{0,55}\n", number);

outputBlock.Text += "\nThe smallest number of the series is:\n";
outputBlock.Text += String.Format("   {0}\n", smallest);
}
}
// The example displays the following output:
//       The values:
//                                          -9223372036854775807
//                                                            -1
//                                                10359321239000
//                                                   10813504144
//                                                70366596661249
//                        85070591730234615852008593798364921858
//                                                             0
//
//       The smallest number of the series is:
//          -9223372036854775807.

```

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.