double precision problem
-
how to set the precision of double type in c#? by default, 1/3=0.33333333333333, output from c#, If I want to the output is only 0.33, that means the output is only two number after the point. thanks
-
how to set the precision of double type in c#? by default, 1/3=0.33333333333333, output from c#, If I want to the output is only 0.33, that means the output is only two number after the point. thanks
double type makes round by defect. If you wan't round you have to use real...
Visit my blog at http://dotnetforeveryone.blogspot.com
-
how to set the precision of double type in c#? by default, 1/3=0.33333333333333, output from c#, If I want to the output is only 0.33, that means the output is only two number after the point. thanks
If it is just the display output you want :-
static void Main(string[] args) { double d = 1.0 / 3.0; Console.WriteLine(d);//0.3333333333 Console.WriteLine("{0:0.00}", d);//0.33 }
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."