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(Int64).

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))
      outputBlock.Text += String.Format("Both methods create a BigInteger whose value is {0}.",
                        constructedNumber) + "\n";
   else
      outputBlock.Text += String.Format("{0} ≠ {1}", constructedNumber, assignedNumber) + "\n";

}
// The example displays the following output:
//    Both methods create a BigInteger whose value is 0.
//    Both methods create a BigInteger whose value is 16704.
//    Both methods create a BigInteger whose value is 199365.
//    Both methods create a BigInteger whose value is 4294967295.


Silverlight

Supported in: 5, 4

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

Community Additions

ADD
Show:
© 2014 Microsoft