|
|
|
How to Floor, Round, Ceiling in JSTL/EL
2
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))}




Just wanted to pointed out two things.
1. In JSTL 1.1 you can't use the ? operator.
2. (1-(N%1))%1 can be simply done as (1-(N%1)).
Thanks!