C# Convert ToDecimal(Single)
Description
Convert ToDecimal(Single)
converts the value of the
specified single-precision floating-point number to the equivalent decimal
number.
Syntax
Convert.ToDecimal(Single)
has the following syntax.
public static decimal ToDecimal(
float value
)
Parameters
Convert.ToDecimal(Single)
has the following parameters.
value
- The single-precision floating-point number to convert.
Returns
Convert.ToDecimal(Single)
method returns A decimal number that is equivalent to value.
Example
/* w w w .j a va 2s . co m*/
using System;
public class MainClass{
public static void Main(String[] argv){
Console.WriteLine(Convert.ToDecimal(1234567500.12F));
Console.WriteLine(Convert.ToDecimal(1234568500.12F));
Console.WriteLine(Convert.ToDecimal(10.980365F));
Console.WriteLine(Convert.ToDecimal(10.980355F));
}
}
The code above generates the following result.