开发者

format a double to 8 decimal places

I have a method that i want to return as a double with 8 dp.

so i开发者_运维问答 have a value coming back from a sp and in the code i am simply doing

CheckSum = double.Parse(cmd.ExecuteScalar().ToString());

however, if the sp returns this :1541338.2349537 the returned double only has those 7dp, when i would like it to put a trailing zero on. like this.. 1541338.23495370

i cant find a method on the double to format it - ie force it to 8dp, other than to return a formatted string. which i dont want to do. can someone explain please :)

thanks

nat


double d = 0.123456789;
string sDisplayValue = d.ToString("0.00000000");


double inputValue = 14.42564678942;
inputValue = Math.Round(inputValue, 8);

Output is 14.42564679

This will preserve the double and will not need a conversion to string

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜