JSTL double保留小数点后两位

首先加入标签库

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

具体代码

<fmt:formatNumber type="number" value="${totalPrice-clothesPrice}" maxFractionDigits="2"/>

maxFractionDigits 代表精确到小数点后 的位数

时间: 2024-07-30 13:41:03

JSTL double保留小数点后两位的相关文章

JAVA除法保留小数点后两位的两种方法 Java Math的 floor,round和ceil的总结

floor 返回不大于的最大整数 round 则是4舍5入的计算,入的时候是到大于它的整数round方法,它表示“四舍五入”,算法为Math.floor(x+0.5),即将原来的数字加上0.5后再向下取整,所以,Math.round(11.5)的结果为12,Math.round(-11.5)的结果为-11. ceil 则是不小于他的最小整数 看例子   Math.floor Math.round Math.ceil 1.4 1 1 2 1.5 1 2 2 1.6 1 2 2 -1.4 -2 -1

js如何实现数字保留小数点后两位小数

js如何实现数字保留小数点后两位小数:小数点后保留两位小数是比较常见的形式,由于比较简单,下面直接给出例子.代码如下: var num=3.1415926; console.log(num.toFixed(2)); toFixed()函数可以参阅javascript的Number对象的toFixed()方法一章节. 原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=9567 更多内容可以参阅:http://www.softwhy.

mysql格式化小数保留小数点后两位(小数点格式化)

格式化浮点数的问题,用format(col,2)保留两位小数点,出现一个问题,例如下面的语句,后面我们给出解决方法 SELECT FORMAT(12562.6655,2); 结果:12,562.67 查看文档:Formats the number X to a format like '#,###,###.##', rounded to D decimal places, and returns the result as a string. If D is 0, the result has

input输入框只能输入正数和小数(保留小数点后两位)

1.限制只能输入正数和小数保留小数点后两位 1 <input type="number" id="txtNum" /> 2 3 <script type="javascript"> 4 $(function(){ 5 $("#txtNum").keyup(function () { 6 $(this).val(ChangeNumValue($(this).val())); 7 }); 8 9 10 })

Android 保留小数点后两位,并采取四舍五入

//小数点后两位四舍五入 private double formatDouble2(double d) { BigDecimal bigDecimal = new BigDecimal(d); double bg = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); return bg; } 原文地址:https://www.cnblogs.com/niupi/p/11428915.html

限制输入,输入金额 和保留小数点后两位

//判断是否是浮点类型 + (BOOL)isPureFloat:(NSString*)string { NSScanner* scan = [NSScanner scannerWithString:string]; float val; return [scan scanFloat:&val] && [scan isAtEnd];} //在textFiled中限制输入位数 if ([string isEqualToString:@""]) { return YE

Double类型的数据四舍五入保留小数点后两位

4种方法,都是四舍五入,例: import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFormat; public class format { double f = 111231.5585; public void m1() { BigDecimal bg = new BigDecimal(f); double f1 = bg.setScale(2, BigDecimal.ROUND

EL表达式,保留小数点后两位

你遇到过页面显示小数有9.987870488E9这个吗? 这是因为没有保留小数的原因 有时候用js保留小数很麻烦的时候,可以用EL表达式 <fmt:formatNumber type="number" value="${member.loginBonusAmount } " maxFractionDigits="2"/> maxFractionDigits:保留几位小数 记住在页面开始需要导入下面的包 <%@ taglib ur

IOS字符串截取保留小数点后两位

-(NSString*)getTheCorrectNum:(NSString*)tempString { //计算截取的长度 NSUInteger endLength = tempString.length; //判断字符串是否包含 . if ([tempString containsString:@"."]) { //取得 . 的位置 NSRange pointRange = [tempString rangeOfString:@"."]; NSLog(@&quo