freemarker中的round、floor和ceiling数字的舍入处理

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

freemarker中的round、floor和ceiling数字的舍入处理,布布扣,bubuko.com

时间: 2024-08-06 10:59:11

freemarker中的round、floor和ceiling数字的舍入处理的相关文章

freemarker中的round、floor和ceiling数字的舍入处理 1

http://www.qdmm.com/BookReader/113167,54166719.aspx http://www.qdmm.com/BookReader/113167,54166867.aspx http://www.qdmm.com/BookReader/113167,54166868.aspx http://www.qdmm.com/BookReader/113167,54166869.aspx http://www.qdmm.com/BookReader/113167,5416

C++中的 Round(),floor(),ceil()

 2.1             2.6               -2.1               -2.6floor : 不大于自变量的最大整数             2                2                  -3                  -3ceil   :不小于自变量的最大整数              3                3                  -2                  -2round:四舍五入到

js中Math.round、parseInt、Math.floor和Math.ceil小数取整总结(转)

js中Math.round.parseInt.Math.floor和Math.ceil小数取整总结 Math.round.parseInt.Math.floor和Math.ceil 都可以返回一个整数,具体的区别请看下面的总结. 一.Math.round 作用:四舍五入,返回参数+0.5后,向下取整. 如: Math.round(5.57) //返回6 Math.round(2.4) //返回2 Math.round(-1.5) //返回-1 Math.round(-5.8) //返回-6 二.

FreeMarker中if标签内的判断条件

reeMarker中的<#if>标签除了里面直接判断 boolean 类型的变量外,也可以进行表达式判断,有几个细节记录一下 1. 判断对象是否存在(null) 经常会用到,如果对象 != null 则xxxx,在freemarker中表达比较奇怪,例如判断 target 是否为null,如果不为 nll 则做xxx动作 <#if target??> xxxx </#if> (目标变量后面连续两个??) 2. 字符串或数字比较 java里标准字符串比较需要 .equal

FreeMarker中的运算符优先级

FreeMarker中的运算符优先级如下(由高到低排列): 1,一元运算符:! 2,内建函数:? 3,乘除法:*, / , % 4,加减法:- , + 5,比较:> , < , >= , <= (lt , lte , gt , gte) 6,相等:== , = , != 7,逻辑与:&& 8,逻辑或:|| 9,数字范围:.. 实际上,我们在开发过程中应该使用括号来严格区分,这样的可读性好,出错少.

FreeMarker中的日期时间处理

1. FreeMarker中的日期时间格式设置 FreeMarker中可以分别对date.time.datetime三种类型的日期时间设置格式,例如: config.setDateTimeFormat("yyyy-MM-dd HH:mm:ss"); config.setDateFormat("yyyy-MM-dd"); config.setTimeFormat("HH:mm:ss"); 当我们对一个页面变量使用 ?date ?time ?date

数组中只出现一次的数字(剑指offer)思维有点巧

数组中只出现一次的数字 参与人数:1144时间限制:1秒空间限制:32768K 通过比例:21.75% 最佳记录:0 ms|0K(来自  牛客563536号) 题目描述 一个整型数组里除了两个数字之外,其他的数字都出现了两次.请写程序找出这两个只出现一次的数字. 题目链接:http://www.nowcoder.com/practice/e02fdb54d7524710a7d664d082bb7811?rp=2&ru=/ta/coding-interviews&qru=/ta/coding

数组中只出现一次的数字-剑指Offer

数组中只出现一次的数字 题目描述 一个整型数组里除了两个数字之外,其他的数字都出现了两次.请写程序找出这两个只出现一次的数字. 思路 先考虑一个数组里只有一个数出现一次,其他两个数都出现两次的情况:一个数跟自己异或后为0,一个数组里只有一个数出现一次其他两次,挨个异或后最后得到的结果就是只出现一次的那个数. 我们把这个数组分为两部分,每部分只有一个数只出现一次:我们分的时候,把所有数都异或后,得到的结果肯定不为0,其实是那两个只出现一次的不同的数的异或,我们从低位到高危找到第一个不为0的那位,异

Freemarker中大于号&gt;的使用

在Freemarker中,比较数据的大小时候,要注意大于号(>)的使用.如果不注意,程序就会发生异常信息,如下面的例子: 1 2 3 4 <#assign x = 4> <#if x>5 > x >5 </#if> 以上的方式进行比较,就会发生异常,原因是Freemarker内部的解析处理原因,x>5中的大于号将会跟<#if中的小于号进行配对,导致解析出现问题.针对这种情况,有两种方式解决:方法一:加上括号. 1 2 3 4 <#as