Home » C#.Net

double keyword in C#

C# double keyword: Here, we are going to learn about the double keyword in C#, what is double keyword, how to use it in C#?
Submitted by IncludeHelp, on March 07, 2019

C# double keyword

In C#, float is a keyword which 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. float keyword 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;

C# code to demonstrate example of double keyword

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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.