Single
, Double
In C# programming, we hear about float
and double
. But these types are syntactic sugar—we can refer to them as Single
and Double
.
They have no differences from the common types they are aliased to. In C# programming, we often hear about a Double
, but less commonly about a Single
.
To understand Single
and Double
, we can simply remember that float
is the same thing as Single
. One type is aliased to another at the language level.
float -> Single double -> Double
This program creates an instance of the Single
and Double
types. It then prints their types to the console window. Then it does the same thing for the float
and double
types.
Single
type is the same as the float
type, and the Double
type is the same as the (lowercase) double
type.using System; { Single a = 1; Double b = 1; Console.WriteLine(a.GetType()); Console.WriteLine(b.GetType()); } { float a = 1; double b = 1; Console.WriteLine(a.GetType()); Console.WriteLine(b.GetType()); }System.Single System.Double System.Single System.Double
The Single
and Double
types are precisely equivalent to the float
and double
types. It is more conventional for C-style language programmers to use float
than Single
.
float
is less likely to confuse other programmers who might then introduce bugs.This article doesn't provide useful examples for Single
or Double
. It demonstrates that these types are precisely equivalent to the float
and double
types.