Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

BigInteger Constructor (Int64)

Initializes a new instance of the BigInteger structure using a 64-bit signed integer value.

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

public BigInteger(
	long value
)

Parameters

value
Type: System.Int64
A 64-bit signed integer.

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

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

The following example calls the BigInteger(Int64) constructor to instantiate BigInteger values from an array of 64-bit integers. It also uses implicit conversion to assign each 64-bit integer value to a BigInteger variable. It then compares the two values to establish that the resulting BigInteger values are the same.


long[] longs = { Int64.MinValue, -10534, -189, 0, 17, 113439,
                 Int64.MaxValue };
BigInteger constructed, assigned;

foreach (long number in longs)
{
   constructed = new BigInteger(number);
   assigned = number;
   outputBlock.Text += String.Format("{0} = {1}: {2}", constructed, assigned,
                     constructed.Equals(assigned)) + "\n";
}
// The example displays the following output:
//       -2147483648 = -2147483648: True
//       -10534 = -10534: True
//       -189 = -189: True
//       0 = 0: True
//       17 = 17: True
//       113439 = 113439: True
//       2147483647 = 2147483647: True      


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:
© 2015 Microsoft