Convert::ToDouble Method (Single)

 

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

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

public:
static double ToDouble(
	float value
)

Parameters

value
Type: System::Single

The single-precision floating-point number.

Return Value

Type: System::Double

A double-precision floating-point number that is equivalent to value.

The following example converts a Single value to a Double value.

public:
   void CovertDoubleFloat( double doubleVal )
   {
      float floatVal = 0;

      // A conversion from Double to Single cannot overflow.
      floatVal = System::Convert::ToSingle( doubleVal );
      System::Console::WriteLine( " {0} as a float is {1}",
                                  doubleVal, floatVal );

      // A conversion from Single to Double cannot overflow.
      doubleVal = System::Convert::ToDouble( floatVal );
      System::Console::WriteLine( " {0} as a double is: {1}",
                                  floatVal, doubleVal );
   }

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: