-1

Possible Duplicate:
Built in .Net algorithm to round value up to the nearest 10 interval

HI, i need a Method that returns next number of the 5er row. example: 3 -> 5 7 -> 10 8 -> 10 16 ->20

how can i do that? thx

Community
  • 1
  • 1
  • I voted to close "exact duplicate". http://stackoverflow.com/questions/274439/built-in-net-algorithm-to-round-value-up-to-the-nearest-10-interval – Andrew Hare Jun 17 '09 at 11:50
  • Not an exact duplicate -- he wants to always round up, not to the nearest. – tvanfosson Jun 17 '09 at 11:52

2 Answers2

2

For positive values:

int rounded  = 5 * Math.Ceiling( (double)original / 5 );
tvanfosson
  • 524,688
  • 99
  • 697
  • 795
0
   int rounded = original + (5 - original%5);        
b.roth
  • 9,421
  • 8
  • 37
  • 50