0

I want to convert the double value to round up value. That means if a number 12.2 means it converted to 13. How can i convert this using c#

4

4 回答 4

5

Simple:

int result = (int)Math.Ceiling(value);
于 2012-07-30T10:51:25.873 回答
1

Using System.Math.Ceiling is nice. Example:

int output = (int)Math.Ceiling(12.2);
于 2012-07-30T11:28:57.187 回答
0

Use System.Math.Ceiling method, which does the job

于 2012-07-30T10:52:27.987 回答
0

Using Math.Ceiling is the simplest way:

double input = 12.2;
int output = (int)Math.Ceiling(input);
textBox1.Text = output.ToString(); //if you want to show it in a textBox
于 2012-07-30T11:15:40.763 回答