Hi,
I am just doing a divide and multiplication process like below;
-----------
double a=2;
double b=3;
double c =(a/b) *100;
-----------
The result is "66.666666666666657". I wanna show only first 2 character from start, "66". How can I do that?
Showing 2 character from a double variable
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Datta KharadRank #2,135 · 668 reputationPosted Nov 1, 2011, 11:27 PM EDT
If you want result like 66 then you should typecasting from double to int. You can try this code.....
double a=2;
double b=3;
int c=(int)((a/b)*100);
Result c=66.
If you got solution then Mark as Accepted Answer.
Suthish NairRank #92 · 22.8K reputationPosted Nov 2, 2011, 12:30 AM EDT
double a1 = 2;
double b1 = 3;
double c1 = (a1 / b1) * 100;
Console.WriteLine(Math.Floor(c1));
double a2 = 2;
double b2 = 3;
double c2 = (a2 / b2) * 100;
Console.WriteLine((int)c2);
Console.ReadLine();
yokzuRank #5,421 · 300 reputationPosted Nov 2, 2011, 1:04 AM EDT