C# Decimal ToSingle
Description
Decimal ToSingle
converts the value of the specified
Decimal to the equivalent single-precision floating-point number.
Syntax
Decimal.ToSingle
has the following syntax.
public static float ToSingle(
decimal d
)
Parameters
Decimal.ToSingle
has the following parameters.
d
- The decimal number to convert.
Returns
Decimal.ToSingle
method returns A single-precision floating-point number equivalent to the value of d.
Example
The following code example converts Decimal numbers to Single values using the ToSingle method.
using System;/* w w w . j a v a 2s.c o m*/
class MainClass
{
public static void Main( )
{
object SingleValue;
SingleValue = decimal.ToSingle( 0.0000000000123456789123456789M );
Console.WriteLine( SingleValue );
}
}
The code above generates the following result.