access 四舍五入问题
时间:2020-08-10 访问量:1157
最终用的:int((字段)*100+5)/100
下面的(但如果是整数,结果就不对了)
Access数据库中Round用法
四舍五入的问题
select round(83.124,2) as t from jqdltb
显示为:83.12
select round(83.125,2) as t from jqdltb
显示为:83.12
select round(83.126,2) as t from jqdltb
显示为:83.13
问题来了,就是四舍五入怎么变成五舍六入了呢?
下面是用这个方法来调整达到四舍五入的方法:
使用int函数和加0.005,然后*100,再然后/100
如下所示:
select int((83.121+0.005)*100)/100 as t from jqdltb
显示为:83.12
select int((83.124+0.005)*100)/100 as t from jqdltb
显示为:83.12
select int((83.125+0.005)*100)/100 as t from jqdltb
显示为:83.13
select int((83.126+0.005)*100)/100 as t from jqdltb
显示为:83.13
select int((83.129+0.005)*100)/100 as t from jqdltb
显示为:83.13