function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

rounding up

I'm using the standardSetController to implement pagination in a VF page.  In my controller I have a property totalPages that returns an integer.  The problem is that the value is not rounding up.  For example, if I have a resultSize of 200 and a pageSize of 5, the totalPages should be 40.  If I have a resultSize of 7 and pageSize of 5, the totalPages should be 2.


I've been digging thru the math methods trying to get the value to round up correctly.


I've tried the following:



Decimal totalPages = Decimal.valueOf(setCtrl.getResultSize() / setCtrl.getPageSize()).round(RoundingMode.UP);
			return totalPages.intValue();

 It is not rounding up.  Can anyone help with how I can get my totalPages to round up correctly?


Thanks for any help.


Try creating an integer variable and assigning a rounded value of the total pages decimal value to that variable. 




Hi ,


use math.round(); function it will help you