c#格式化字float_C#中的float关键字
c#格式化字float
C#float關鍵字 (C# float 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 4 bytes (32 bits) space in the memory.
它在內存中占用4個字節(32位)的空間。
Note: To represent a float value, we use a suffix f or F with the value.
注意:為了表示浮點值,我們使用后綴f或F。
Syntax:
句法:
float variable_name = value;C#代碼演示float關鍵字示例 (C# code to demonstrate example of float keyword)
Here, we are declaring a float variable num, initializing it with the value 12345.6789f and printing its value, type and size of a float type variable.
在這里,我們聲明一個float變量num ,使用值12345.6789f對其進行初始化,并打印其值,類型和float類型變量的大小。
using System; using System.Text;namespace Test {class Program{static void Main(string[] args){//variable declarationfloat num = 12345.6789f;//printing valueConsole.WriteLine("num: " + num);//printing type of variableConsole.WriteLine("Type of num: " + num.GetType());//printing sizeConsole.WriteLine("Size of a float variable: " + sizeof(float));//printing minimum & maximum value of floatConsole.WriteLine("Min value of float: " + float.MinValue);Console.WriteLine("Max value of float: " + float.MaxValue);//hit ENTER to exitConsole.ReadLine();}} }Output
輸出量
num: 12345.68 Type of num: System.Single Size of a float variable: 4 Min value of float: -3.402823E+38 Max value of float: 3.402823E+38翻譯自: https://www.includehelp.com/dot-net/float-keyword-in-c-sharp.aspx
c#格式化字float
總結
以上是生活随笔為你收集整理的c#格式化字float_C#中的float关键字的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: css导航栏_使用CSS的导航栏
- 下一篇: c#中将整数转化为字符串_在C#中将字符