# Decimal Narrowing Conversion (Decimal to Double)

Silverlight

Converts a Decimal to a double-precision floating-point number.

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

## Syntax

```'Declaration
Public Shared Narrowing Operator CType ( _
value As Decimal _
) As Double
```

#### Parameters

value
Type: System.Decimal
A Decimal to convert.

#### Return Value

Type: System.Double
A double-precision floating-point number that represents the converted Decimal.

## Remarks

This operation can produce round-off errors because a double-precision floating-point number has fewer significant digits than a Decimal.

This operator supports the explicit conversion of a Decimal to a Double. The syntax for such explicit conversions is language-dependent, and individual language compilers can provide different implementations and return different results. The example illustrates the different return values when you explicitly convert a Decimal value to a Double value by using C# and Visual Basic. To perform a conversion that is independent of language, you can call the ToDouble or the Convert.ToDouble(Decimal) method.

## Examples

The following code example converts Decimal numbers to Double values using the explicit Decimal to Double conversion.

```
' Example of the explicit conversions from decimal to float and
' decimal to double.
Module Example

Const formatter As String = "{0,30}{1,17}{2,23}"

' Convert the Decimal argument to a floating point value
' No exceptions are thrown.
Public Sub DecimalToSgl_Dbl(ByVal outputBlock As System.Windows.Controls.TextBlock, ByVal argument As Decimal)
Dim SingleValue As Single
Dim DoubleValue As Double

' Convert the argument to a Single value.
SingleValue = CSng(argument)

' Convert the argument to a Double value.
DoubleValue = CDbl(argument)

outputBlock.Text += String.Format(formatter, argument, _
SingleValue, DoubleValue) + vbCrLf
End Sub

Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
outputBlock.Text += String.Format(formatter, "Decimal argument", _
"Single", "Double") + vbCrLf
outputBlock.Text += String.Format(formatter, "----------------", _
"-----", "------") + vbCrLf

' Convert decimal values and display the results.
DecimalToSgl_Dbl(outputBlock, 0.0000000000000000000000000001D)
DecimalToSgl_Dbl(outputBlock, 0.0000000000123456789123456789D)
DecimalToSgl_Dbl(outputBlock, 123D)
DecimalToSgl_Dbl(outputBlock, New Decimal(123000000, 0, 0, False, 6))
DecimalToSgl_Dbl(outputBlock, 123456789.123456789D)
DecimalToSgl_Dbl(outputBlock, 123456789123456789123456789D)
DecimalToSgl_Dbl(outputBlock, Decimal.MinValue)
DecimalToSgl_Dbl(outputBlock, Decimal.MaxValue)
End Sub
End Module
' The example displays the following output:
'                  Decimal argument           Single                 Double
'                  ----------------            -----                 ------
'    0.0000000000000000000000000001            1E-28                  1E-28
'    0.0000000000123456789123456789     1.234568E-11   1.23456789123457E-11
'                               123              123                    123
'                        123.000000              123                    123
'               123456789.123456789     1.234568E+08       123456789.123457
'       123456789123456789123456789     1.234568E+26   1.23456789123457E+26
'    -79228162514264337593543950335    -7.922816E+28  -7.92281625142643E+28
'     79228162514264337593543950335     7.922816E+28   7.92281625142643E+28

```

## Version Information

#### Silverlight

Supported in: 5, 4, 3

#### Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

#### XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

## Platforms

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