Single and Double TypesReview the Single and Double types. These types are known as float and double.
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.
Some type notes. 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.
Alias chart. 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
An example. 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.
And This shows us that the Single type is the same as the float type, and the Double type is the same as the (lowercase) double type.
using System; class Program { static void Main() { { 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
A discussion. 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.
Also Code written with float is less likely to confuse other programmers who might then introduce bugs.
A summary. 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.
Dot Net Perls is a collection of tested code examples. Pages are continually updated to stay current, with code correctness a top priority.
Sam Allen is passionate about computer languages. In the past, his work has been recommended by Apple and Microsoft and he has studied computers at a selective university in the United States.
No updates found for this page.
© 2007-2023 Sam Allen.