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
Assemblies:   System.Runtime.Numerics (in System.Runtime.Numerics.dll)
  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.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1
Show:
© 2015 Microsoft