1 #include<stdio.h> 2 int main() 3 { 4 float num; 5 int temp; 6 scanf("%f",&num); 7 temp=num*100+0.5; 8 num=(double)temp/100; 9 printf("%f",num); //不同 ...
分类:
其他好文 时间:
2021-04-12 12:28:11
阅读次数:
0
public class DoubleFormat { double f = 111231.4585; public void m1() { BigDecimal bg = new BigDecimal(f); double f1 = bg.setScale(2, BigDecimal.ROUND_ ...
分类:
其他好文 时间:
2020-11-25 12:18:08
阅读次数:
5
最近做公司前端,需要input输入框控制为正数,且小数点最多为两位。 我用的: /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/ 网上另外一个很好的例子: 只能正数金额:(^[1-9](\d+)?(\.\d{1,2})?$)|(^0$ ...
分类:
其他好文 时间:
2020-09-16 12:02:47
阅读次数:
61
var num =2.446242342; num = num.toFixed(2); // 输出结果为 2.45 另外像 round()、floor()、ceil() 等都不能真正的四舍五入,有精度问题。 round() 可以通过以下方式来确保精度是正确的: var num =2.44624234 ...
分类:
Web程序 时间:
2020-07-30 14:14:37
阅读次数:
87
html页面: { field: 'suppliersLevel', align: 'center', title: '供应商级别', formatter:function(value, row, index){ if(value==0){ return value; }else{ var keep ...
分类:
Web程序 时间:
2020-07-29 15:31:43
阅读次数:
93
let a=1; let b=2; let sun=a+b; // 同时扩大100 let am=a*100; let bm=b*100; let sunm=sun*100; // toFixed(2 );保留位数2的同时四舍五入 console.log( ((am/sunm)*100).toFix ...
分类:
其他好文 时间:
2020-07-23 16:48:44
阅读次数:
141
原博客连接:https://blog.csdn.net/Jerry_1126/article/details/85009810 保留两位小数,并做四舍五入处理 方法一:使用字符串格式化 a = 12.345 print("%.2f" % a) # 12.35 方法二: 使用round内置函数 a = ...
分类:
编程语言 时间:
2020-07-20 15:28:17
阅读次数:
151
参考: https://www.cnblogs.com/En-summerGarden/p/10145295.html //只能输入整数 function Integer(obj) { if (obj.value.length == 1) { obj.value = obj.value.replac ...
分类:
Web程序 时间:
2020-07-20 10:56:19
阅读次数:
153
/** * @param {*} money[输入的money] * @param {string} [货币符号,sysmbol='¥'] * @param {number} [小数点位数,places=2] * @returns undefined */ function dealMoney(mo ...
分类:
编程语言 时间:
2020-07-13 18:45:19
阅读次数:
76
function formatMoney(val, row) { if (!isNaN(val)) { var source = String(val.toFixed(2)).split("."); //按小数点分成2部分 source[0] = source[0].replace( new Reg ...
分类:
Web程序 时间:
2020-06-18 19:44:28
阅读次数:
96