I am using Expression Language (EL) in JSP.
<c:set var="noOfPages" value="${numItems/itemsPerPage}" />
<fmt:formatNumber var="noOfPagesRounded" value="${noOfPages}" maxFractionDigits="0" />
<c:if test="${(numItems % itemsPerPage) > 0}">
<c:set var="noOfPages" value="${noOfPagesRounded + 1}"/>
</c:if >
As you see I am calculating no. of pages required to display x
no. of results per page.
This doesn't work all time since at line 2 i.e. formatNumber
tag is rounding of my division results, which I don't want to get rounded off.
i.e. for 73 records 20 per page needs 4 pages but I am getting result 5, because at line 2 it is rounding of result 3.65 to 4 but I want noOfPagesRounded=3
.
How should I convert float
or double
value in int
without rounding off?