小数 ###_C#中的小数关键字
小數 ###
C#十進制關鍵字 (C# decimal keyword)
In C#, decimal is a keyword which is used to declare a variable that can store a floating type value (value with the precision) between the range of ±1.0 x 10-28 to ±7.9228 x 1028. decimal keyword is an alias of System.Decimal.
在C#中, 十進制是一個關鍵字,用于聲明一個變量,該變量可以存儲介于±1.0 x 10 -28到±7.9228 x 10 28范圍內的浮點型值(精度值)。 十進制關鍵字是System.Decimal的別名。
It occupies 16 bytes (128 bits) in the memory.
它在內存中占用16個字節(128位)。
Note: To represent a decimal value, we use m or M as a suffix with the literal.
注意:為了表示一個十進制值,我們使用m或M作為文字的后綴。
Syntax:
句法:
decimal variable_name = value;It can store the value between the range of ±1.0 x 10-28 to ±7.9228 x 1028.
它可以存儲介于±1.0 x 10 -28到±7.9228 x 10 28之間的值 。
C#代碼演示小數關鍵字的示例 (C# code to demonstrate example of decimal keyword)
Here, we are declaring a decimal variable num, initializing it with the value 5610.2361m and printing its value, type and size of a decimal type variable.
在這里,我們聲明一個十進制變量num ,使用值5610.2361m對其進行初始化,并打印其值,類型和十進制類型變量的大小。
using System; using System.Text;namespace ConsoleApplication3 {class Program{static void Main(string[] args){//char variable declarationdecimal num = 5610.2361m;//printing valueConsole.WriteLine("num: " + num);//printing type of variableConsole.WriteLine("Type of num: " + num.GetType());//printing size of a decimal Console.WriteLine("Size of a decimal variable: " + sizeof(decimal));//hit ENTER to exitConsole.ReadLine();}} }Output
輸出量
num: 5610.2361 Type of num: System.Decimal Size of a decimal variable: 16翻譯自: https://www.includehelp.com/dot-net/decimal-keyword-in-c-sharp.aspx
小數 ###
總結
以上是生活随笔為你收集整理的小数 ###_C#中的小数关键字的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 地下城与勇士鬼剑士转什么好
- 下一篇: 颐和园购票优惠政策