Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decimal to string conversion issue

Tags:

c#

Math.Round((ClosePrice - OpenPrice), 5) = -0.00001

But When I convert it into tostring it gives "-1E-05"

Math.Round((ClosePrice - OpenPrice), 5).ToString() = "-1E-05"

Why this is so ? How can I get "-0.00001"

like image 757
SOF User Avatar asked Dec 03 '22 05:12

SOF User


1 Answers

You can use format specifier as demonstrated on MSDN's Standard Numeric Format Strings

double foo = -0.00001;
Console.WriteLine(foo.ToString("f5"));
like image 164
Prafulla Avatar answered Dec 05 '22 18:12

Prafulla