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#

rom fernando
  • 71
  • 1
  • 5
  • 13

4 Answers4

5

Simple:

int result = (int)Math.Ceiling(value);
SynerCoder
  • 12,493
  • 4
  • 47
  • 78
1

Using System.Math.Ceiling is nice. Example:

int output = (int)Math.Ceiling(12.2);
0

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

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