tags:

views:

68

answers:

2

Hi

I need to round numbers to 0 decimals (for a pagging system).

I've already tried something like this:

Math.Round(double1, 0, MidpointRounding.AwayFromZero);

If the double1 be 7,2 or 7,6 i need it to round for 8 but i'm not getting that.

Can someone help me, please?

Thanks

+7  A: 

Use Math.Ceiling to always round up to the next integer:

double roundUp = Math.Ceiling(double1); 
RedFilter
Thanks, that was exacly what i was looking for.
Guilherme Cardoso
+1  A: 

If you don't want to use Math.Ceiling, for some reason - you could do:

 public int Ceil(double x) {
  return (int) x + ((int) x < x ? 1 : 0);
 }
Margus