How to Floor, Round, Ceiling in JSTL/EL





2
Date Submitted Fri. Mar. 5th, 2010 2:48 PM
Revision 1 of 1
Scripter Fordiman
Tags "Expression Language" | EL | JSTL
Comments 1 comments
In JSTL and EL, there is not floor, round, or ceiling function. Here is some relatively uncomplex ways to achieve the same effect.

Floor(N) -> ${N-(N%1)}
Ceiling(N) -> ${N+(1-(N%1))%1}
Round(N) -> ${N+((N%1>0.5)?(1-(N%1))%1:-(N%1))}
 

Bryan Elliott

www.codemonkeybryan.com

Comments

Comments Cool!
Thu. Oct. 21st, 2010 2:00 PM    Newbie seonghuhn

Voting

Votes Up


Scripter Fordiman
Beginner longkaty

Votes Down