Export (0) Print
Expand All

BigInteger Constructor (Decimal)

Initializes a new instance of the BigInteger structure using a Decimal value.

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

public BigInteger(
	decimal value
)

Parameters

value
Type: System.Decimal

A decimal number.

The result of calling this constructor is identical to explicitly assigning a Decimal value to a BigInteger variable.

Calling this constructor can cause data loss; any fractional part of value is truncated when instantiating a BigInteger object.

The following example illustrates the use of the BigInteger(Decimal) constructor to instantiate a BigInteger object. It defines an array of Decimal values, and then passes each value to the BigInteger(Decimal) constructor. Note that the Decimal value is truncated instead of rounded when it is assigned to the BigInteger object.

decimal[] decimalValues = { -1790.533m, -15.1514m, 18903.79m, 9180098.003m };
foreach (decimal decimalValue in decimalValues)
{
   BigInteger number = new BigInteger(decimalValue);
   Console.WriteLine("Instantiated BigInteger value {0} from the Decimal value {1}.",
                     number, decimalValue);
}                 
// The example displays the following output: 
//    Instantiated BigInteger value -1790 from the Decimal value -1790.533. 
//    Instantiated BigInteger value -15 from the Decimal value -15.1514. 
//    Instantiated BigInteger value 18903 from the Decimal value 18903.79. 
//    Instantiated BigInteger value 9180098 from the Decimal value 9180098.003.

.NET Framework

Supported in: 4.6, 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

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