c#中double_C#中的double关键字

c#中double

C#双关键字 (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.

在C#中, float是一个关键字,用于声明一个变量,该变量可以存储介于±1.5 x 10 -45到±3.4 x 10 38范围内的浮点值。 float关键字是System.Single的别名。

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

它在内存中占用8个字节(64位)的空间。

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.

注意:不使用任何后缀的任何浮点值都被视为双精度值。 我们还可以指定后缀d或D来表示双精度值。

Syntax:

句法:

    double variable_name = value;

C#代码演示double关键字示例 (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.

在这里,我们声明一个双精度变量num ,使用值12345.6789对其进行初始化,并打印其值,类型和double型变量的大小。

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


翻译自: https://www.includehelp.com/dot-net/double-keyword-in-c-sharp.aspx

c#中double

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值