This documentation is archived and is not being maintained.

Decimal Constructor (Int32, Int32, Int32, Boolean, Byte)

Initializes a new instance of Decimal from parameters specifying the instance's constituent parts.

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

new : 
        lo:int * 
        mid:int * 
        hi:int * 
        isNegative:bool * 
        scale:byte -> Decimal

Parameters

lo
Type: System.Int32
The low 32 bits of a 96-bit integer.
mid
Type: System.Int32
The middle 32 bits of a 96-bit integer.
hi
Type: System.Int32
The high 32 bits of a 96-bit integer.
isNegative
Type: System.Boolean
true to indicate a negative number; false to indicate a positive number.
scale
Type: System.Byte
A power of 10 ranging from 0 to 28.

ExceptionCondition
ArgumentOutOfRangeException

scale is greater than 28.

The binary representation of a Decimal number consists of a 1-bit sign, a 96-bit integer number, and a scaling factor used to divide the integer number and specify what portion of it is a decimal fraction. The scaling factor is implicitly the number 10 raised to an exponent ranging from 0 to 28.

The following code example creates several Decimal numbers using the constructor overload that initializes a Decimal structure with three Int32 value words, a Boolean sign, and a Byte scale factor.

No code example is currently available or this language may not be supported.

The following example uses the GetBits method to retrieve the component parts of an array. It then uses this array in the call to the Decimal constructor to instantiate a new Decimal value.


Module Example
   Public Sub Main()
      Dim values() As Decimal = { 1234.96d, -1234.96d }
      For Each value In values
         Dim parts() = Decimal.GetBits(value)
         Dim sign As Boolean = (parts(3) And &h80000000) <> 0
         Dim scale As Byte = CByte((parts(3) >> 16) And &H7F)

         Dim newValue As New Decimal(parts(0), parts(1), parts(2), sign, scale)    
         Console.WriteLine("{0} --> {1}", value, newValue)
      Next   
   End Sub
End Module
' The example displays the following output:
'    1234.96 --> 1234.96
'    -1234.96 --> -1234.96


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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