Open In App

double Keyword in C#

Improve
Improve
Like Article
Like
Save
Share
Report

Keywords are the words in a language that are used for some internal process or represent some predefined actions. It is a keyword that is used to declare a variable that can store a floating-point value from the range of ±5.0 x 10-324 to ±1.7 x 10308. It is an alias of System.Double. Basically, it is a 64-bit double precision floating point number and have 14 to 15 digit precision.

Double Keyword occupies 8 byte (64 bits) space in the memory.

Syntax:

double variable_name = value;

We can specify a suffix d or D to represent a double value. Also floating point value without using any suffix is considered as a double value.

Example:

Input: num: 1234.5678

Output: num: 1234.5678
        Size of a double variable: 8

Input: num = -67895.4322D

Output: Type of num: System.Double
        num: -67895.4322
        Size of a double variable: 8

Example 1:




// C# program for the double keyword
using System;
using System.Text;
  
class geeks {
  
    static void Main(string[] args)
    {
        // variable declaration
        double num = 1234.5678;
  
        // to print value
        Console.WriteLine("num: " + num);
  
        // to print size
        Console.WriteLine("Size of a double variable: " + sizeof(double));
    }
}


Output:

num: 1234.5678
Size of a double variable: 8

Example 2:




// C# program for the double keyword
using System;
using System.Text;
  
namespace Test {
  
class geeks {
  
    static void Main(string[] args)
    {
        // variable declaration
        double num = -67895.4322D;
  
        // to print type of variable
        Console.WriteLine("Type of num: " + num.GetType());
  
        // to print value
        Console.WriteLine("num: " + num);
  
        // to print size
        Console.WriteLine("Size of a double variable: " + sizeof(double));
  
        // to print 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:

Type of num: System.Double
num: -67895.4322
Size of a double variable: 8
Min value of double: -1.79769313486232E+308
Max value of double: 1.79769313486232E+308


Last Updated : 22 Jun, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads