Home »
C# Tutorial
C# double Keyword with Example
In this tutorial, we will learn about the double keyword, its usage, memory size with example in C#.
By IncludeHelp Last updated : April 04, 2023
C# double Keyword
The double keyword is used to declare a variable that can store a floating point value between the range of ±1.5 x 10−45 to ±3.4 x 1038. The double is an alias of System.Single.
It occupies 8 byte (64 bits) space in the memory.
Note: Any floating point value without using any suffix is considered as a double value. We can also specify a suffix d or D to represent a double value.
Syntax
double variable_name = value;
Example of double keyword in C#
Here, we are declaring a double variable num, initializing it with the value 12345.6789 and printing its value, type, and size of a double type variable.
using System;
using System.Text;
namespace Test {
class Program {
static void Main(string[] args) {
//variable declaration
double num = 12345.6789;
//printing value
Console.WriteLine("num: " + num);
//printing type of variable
Console.WriteLine("Type of num: " + num.GetType());
//printing size
Console.WriteLine("Size of a double variable: " + sizeof(double));
//printing minimum & maximum value of double
Console.WriteLine("Min value of double: " + double.MinValue);
Console.WriteLine("Max value of double: " + double.MaxValue);
//hit ENTER to exit
Console.ReadLine();
}
}
}
Output
num: 12345.6789
Type of num: System.Double
Size of a double variable: 8
Min value of double: -1.79769313486232E+308
Max value of double: 1.79769313486232E+308