Export (0) Print
Expand All

Convert.ToDecimal Method (Single)

Converts the value of the specified single-precision floating point number to the equivalent Decimal number.

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

'Declaration
Public Shared Function ToDecimal ( _
	value As Single _
) As Decimal

Parameters

value
Type: System.Single
A single-precision floating point number.

Return Value

Type: System.Decimal
A Decimal number equivalent to the value of value.

ExceptionCondition
OverflowException

value is greater than Decimal.MaxValue or less than Decimal.MinValue.

The Decimal value returned by this method contains a maximum of 7 significant digits. If the value parameter contains more than seven significant digits, it is rounded using rounding to nearest. The following example illustrates how the Convert.ToDecimal(Single) method uses rounding to nearest to return a Decimal value with 7 significant digits.


outputBlock.Text &= Convert.ToDecimal(1.23456755E+9F) & vbCrLf   ' Displays 1234568000
outputBlock.Text &= Convert.ToDecimal(1.23456845E+9F) & vbCrLf   ' Displays 1234568000

outputBlock.Text &= Convert.ToDecimal(10.9803648F) & vbCrLf       ' Displays 10.98036 
outputBlock.Text &= Convert.ToDecimal(10.9803553F) & vbCrLf       ' Displays 10.98036


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

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

Community Additions

ADD
Show:
© 2014 Microsoft