Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to always round up to the next integer [duplicate]

i am trying to find total pages in building a pager on a website (so i want the result to be an integer. i get a list of records and i want to split into 10 per page (the page count)

when i do this:

list.Count() / 10 

or

list.Count() / (decimal)10 

and the list.Count() =12, i get a result of 1.

How would I code it so i get 2 in this case (the remainder should always add 1)

like image 446
leora Avatar asked Jan 31 '11 00:01

leora


People also ask

How do you round up to the next integer?

Rounding to the Nearest Integer If the digit in the tenths place is less than 5, then round down, which means the units digit remains the same; if the digit in the tenths place is 5 or greater, then round up, which means you should increase the unit digit by one.

How do I always round up in Python?

To implement the “rounding up” strategy in Python, we'll use the ceil() function from the math module. The ceil() function gets its name from the term “ceiling,” which is used in mathematics to describe the nearest integer that is greater than or equal to a given number.

How do you round off to next integer in C#?

The Math. Round() function can be used to round up a double value to the nearest integer value in C#. The Math. Round() function returns a double value that is rounded up to the nearest integer.


1 Answers

Math.Ceiling((double)list.Count() / 10); 
like image 139
Rob Avatar answered Oct 05 '22 23:10

Rob