无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

指定小數(shù)位數(shù)輸出

2023-01-27 21:34 作者:此城過(guò)客  | 我要投稿

static void Main(string[] args)

{

? ? ? ? ?double a = 3.33333333333;

? ? ? ? ?Console.WriteLine("{0:0}",a);//輸出3

? ? ? ? ?Console.WriteLine("{0:0.0}", a);//輸出3.3

? ? ? ? ?Console.WriteLine("{0:0.00}", a);//輸出3.33

? ? ? ? ?Console.WriteLine("{0:0.000}", a);//輸出3.333

? ? ? ? ?string?b = a.ToString("0.00000");

? ? ? ? ?Console.WriteLine(b);//直接輸出b,就是3.33333,一共有5位小數(shù)。

}//假如a.ToString括號(hào)里寫(xiě)的是0.00,那么b就會(huì)輸出3.33。

static void Main(string[] args)

{

? ? ? ? double a = 3.3666666666666;//如果是小數(shù),就會(huì)自動(dòng)四舍五入

? ? ? ? Console.WriteLine("{0:0}",a);//輸出3

? ? ? ? Console.WriteLine("{0:0.0}", a);//輸出3.4

? ? ? ? Console.WriteLine("{0:0.00}", a);//輸出3.37

? ? ? ? Console.WriteLine("{0:0.000}", a);//輸出3.367

? ? ? ? string b = a.ToString("0.00000");//輸出3.36667

? ? ? ??Console.WriteLine(b);

}


指定小數(shù)位數(shù)輸出的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
万安县| 辉南县| 莱西市| 吐鲁番市| 香格里拉县| 英超| 文登市| 湖口县| 屏东市| 疏附县| 沅江市| 张家港市| 黄骅市| 汉阴县| 海安县| 潮州市| 灵璧县| 连南| 周口市| 阜平县| 钦州市| 永昌县| 福安市| 贵南县| 江源县| 宁海县| 长岭县| 海南省| 鹿邑县| 乐昌市| 贵州省| 舒兰市| 连平县| 托里县| 静安区| 抚松县| 顺平县| 双柏县| 石柱| 房山区| 弥勒县|