ToDecimal Method (Single)

Convert.ToDecimal Method (Single)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft