Export (0) Print
Expand All

BigInteger Constructor (UInt32)

Initializes a new instance of the BigInteger structure using an unsigned 32-bit integer value.

This API is not CLS-compliant. The CLS-compliant alternative is BigInteger.

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

[CLSCompliantAttribute(false)]
public BigInteger(
	uint value
)

Parameters

value
Type: System.UInt32

An unsigned 32-bit integer value.

There is no loss of precision when instantiating a BigInteger using this constructor.

The BigInteger value that results from calling this constructor is identical to the value that results from assigning a UInt32 value to a BigInteger.

The following example uses the BigInteger(UInt32) constructor and an assignment statement to initialize BigInteger values from an array of unsigned 32-bit integers. It then compares the two values to demonstrate that the two methods of initializing a BigInteger value produce identical results.

uint[] unsignedValues = { 0, 16704, 199365, UInt32.MaxValue };
foreach (uint unsignedValue in unsignedValues)
{
   BigInteger constructedNumber = new BigInteger(unsignedValue);
   BigInteger assignedNumber = unsignedValue;
   if (constructedNumber.Equals(assignedNumber))
      Console.WriteLine("Both methods create a BigInteger whose value is {0:N0}.",
                        constructedNumber);
   else
      Console.WriteLine("{0:N0} ≠ {1:N0}", constructedNumber, assignedNumber);

}
// The example displays the following output: 
//    Both methods create a BigInteger whose value is 0. 
//    Both methods create a BigInteger whose value is 16,704. 
//    Both methods create a BigInteger whose value is 199,365. 
//    Both methods create a BigInteger whose value is 4,294,967,295.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1

Windows Phone 8.1, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft