freemarker中的round、floor和ceiling数字的舍入处理(十七)

时间:2021-08-21 13:02:53

1、简易说明

(1)round:四舍五入

(2)floor:向下取整

(3)ceiling:向上取整

2、举例说明

      <#--freemarker中的round、floor和ceiling数字的舍入处理-->
      <#--round:四舍五入-->
      <#--floor:向下取整-->
      <#--ceiling:向上取整-->

      <#assign numList = [12,0.23,89,12.03,69.56,45.67,-0.56,-8.05,-89.56,4.69]/>
      <#list numList as num>
          ${num} ?round=${num?round} ?floor=${num?floor} ?ceiling=${num?ceiling}
      </#list>

3、示例结果

 <span style="white-space:pre">    </span> 12 ?round=12 ?floor=12 ?ceiling=12
          0.23 ?round=0 ?floor=0 ?ceiling=1
          89 ?round=89 ?floor=89 ?ceiling=89
          12.03 ?round=12 ?floor=12 ?ceiling=13
          69.56 ?round=70 ?floor=69 ?ceiling=70
          45.67 ?round=46 ?floor=45 ?ceiling=46
          -0.56 ?round=-1 ?floor=-1 ?ceiling=0
          -8.05 ?round=-8 ?floor=-9 ?ceiling=-8
          -89.56 ?round=-90 ?floor=-90 ?ceiling=-89
          4.69 ?round=5 ?floor=4 ?ceiling=5