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#
Asked
Active
Viewed 4,073 times
0
-
Ps. Possible duplicat of http://stackoverflow.com/questions/9295629/round-up-a-double-to-int – SynerCoder Jul 30 '12 at 10:52
4 Answers
1
Using System.Math.Ceiling
is nice.
Example:
int output = (int)Math.Ceiling(12.2);
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

Ionică Bizău
- 109,027
- 88
- 289
- 474