I have done some calculations in two textbox
data type is double
like 9/8

The answer is in point 1.125

how can i make it in complete value. like if it is less than .5 it take 1 as complete number. or if the answer is above .5 then it consider as 2.

and also how to display only two digits after point.

Recommended Answers

All 2 Replies

Use Math:

double pi = 3.14159265;
            Console.WriteLine(Math.Round(pi, 2));  //displays 3.14
            Console.WriteLine(Math.Round(pi, 3));  //displays 3.142
            Console.ReadKey();

See for more info: http://msdn.microsoft.com/en-us/library/wyk4d9cy.aspx#Y342

Hey thank you I realy dont know this math.round method

thank you so much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.