954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

working in double datatype

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.

virusisfound
Junior Poster
172 posts since Jun 2010
Reputation Points: 10
Solved Threads: 2
 

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

C#Jaap
Junior Poster in Training
50 posts since Sep 2009
Reputation Points: 15
Solved Threads: 10
 

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

thank you so much.

virusisfound
Junior Poster
172 posts since Jun 2010
Reputation Points: 10
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: