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)

public static decimal ToDecimal(
	float value


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

Return Value

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


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(1234567500.12F) + "\n";  // Displays 1234568000
outputBlock.Text += Convert.ToDecimal(1234568500.12F) + "\n";  // Displays 1234568000

outputBlock.Text += Convert.ToDecimal(10.980365F) + "\n";      // Displays 10.98036 
outputBlock.Text += Convert.ToDecimal(10.980355F) + "\n";      // Displays 10.98036


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