This documentation is archived and is not being maintained.

Decimal.Division Operator

Divides two specified Decimal values.

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

'Declaration
Public Shared Operator / ( _
	d1 As Decimal, _
	d2 As Decimal _
) As Decimal
'Usage
Dim d1 As Decimal 
Dim d2 As Decimal 
Dim returnValue As Decimal 

returnValue = (d1 / d2)

Parameters

d1
Type: System.Decimal

A Decimal (the dividend).

d2
Type: System.Decimal

A Decimal (the divisor).

Return Value

Type: System.Decimal
The Decimal result of d1 by d2.

ExceptionCondition
DivideByZeroException

d2 is zero.

OverflowException

The return value is less than MinValue or greater than MaxValue.

The following code example creates several pairs of Decimal values and calculates their quotients with the Division operator.

Module DecimalMulDivRemOpsDemo

   Const dataFmt As String = "{0,-38}{1,31}" 

   ' Display Decimal values and their product, quotient, and remainder. 
   Sub ShowDecimalProQuoRem( left As Decimal, right As Decimal )
      Console.WriteLine( dataFmt, "Decimal left", left )
      Console.WriteLine( dataFmt, "Decimal right", right )

      Console.WriteLine(dataFmt, _
           "Decimal.op_Multiply(left, right)", _
            Decimal.op_Multiply(left, right))
      Console.WriteLine(dataFmt, _
            "Decimal.op_Division(left, right)", _
            Decimal.op_Division(left, right))
      Console.WriteLine(dataFmt, _
            "Decimal.op_Modulus(left, right)", _
            Decimal.op_Modulus(left, right))
      Console.WriteLine()
   End Sub 

   Sub Main( )
      ' Create pairs of Decimal objects.
      ShowDecimalProQuoRem( 1000D, 7D ) 
      ShowDecimalProQuoRem( -1000D, 7D ) 
      ShowDecimalProQuoRem( _ 
            new Decimal( 1230000000, 0, 0, False, 7 ), _ 
            0.0012300D )
      ShowDecimalProQuoRem( 12345678900000000D, _
            0.0000000012345678D )
      ShowDecimalProQuoRem( 123456789.0123456789D, _ 
            123456789.1123456789D )
   End Sub 
End Module  
' The example displays the following output: 
'    Decimal left                                                     1000 
'    Decimal right                                                       7 
'    Decimal.op_Multiply(left, right)                                 7000 
'    Decimal.op_Division(left, right)       142.85714285714285714285714286 
'    Decimal.op_Modulus(left, right)                                     6 
'     
'    Decimal left                                                    -1000 
'    Decimal right                                                       7 
'    Decimal.op_Multiply(left, right)                                -7000 
'    Decimal.op_Division(left, right)      -142.85714285714285714285714286 
'    Decimal.op_Modulus(left, right)                                    -6 
'     
'    Decimal left                                              123.0000000 
'    Decimal right                                                 0.00123 
'    Decimal.op_Multiply(left, right)                       0.151290000000 
'    Decimal.op_Division(left, right)                            100000.00 
'    Decimal.op_Modulus(left, right)                             0.0000000 
'     
'    Decimal left                                        12345678900000000 
'    Decimal right                                      0.0000000012345678 
'    Decimal.op_Multiply(left, right)            15241577.6390794200000000 
'    Decimal.op_Division(left, right)       10000000729000059778004901.796 
'    Decimal.op_Modulus(left, right)                        0.000000000983 
'     
'    Decimal left                                     123456789.0123456789 
'    Decimal right                                    123456789.1123456789 
'    Decimal.op_Multiply(left, right)       15241578765584515.651425087878 
'    Decimal.op_Division(left, right)       0.9999999991899999933660999449 
'    Decimal.op_Modulus(left, right)                  123456789.0123456789

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

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

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show: