2013-10-01 25 views
1

長精度數我有一堆別人的統計包,這樣寫代碼,所以:創建在C#

float myValue = 0.0f; 

這使得myvalue的單點精度數。有沒有辦法使它達到五位小數?

這是正確的做法:

float myValue = 0.00000f; 
+4

'0.00000f = 0.0f' – EZI

+1

花車有7位 –

+0

精度是啊,這就是我認爲你們兩個,只要雙擊檢查,thx – cdub

回答

1

f是指定的值是浮動

From msdn : By default, a real numeric literal on the right side of the 
assignment operator is treated as double. Therefore, to initialize a float 
variable, use the suffix f or F 

兩個聲明都是一樣的。如果你想圓五個小數點使用Math.Round()

Math.Round(45.45672234, 5); 
Ans : 45.45672 
+0

當通過Math.Round管道時,將類型更改爲雙精度型。 –