起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 700|回复: 1

对浮点小数,实现四舍五入的方法

[复制链接]
发表于 2004-12-30 09:21:06 | 显示全部楼层 |阅读模式
Business.System.Math.RoundTo(值, 小数位数);

例如:
Expression Value

RoundTo(1234567, 3) 1234000
RoundTo(1.234, -2) 1.23
RoundTo(1.235, -2) 1.24
RoundTo(1.245, -2) 1.24

Business.System.Math.Round 函数可以四舍五入取整数
回复

使用道具 举报

 楼主| 发表于 2004-12-30 09:22:23 | 显示全部楼层

浮点变成整数

可以使用Floor、 Ceil两个函数,都是把浮点变成整数的,结果不一样
Floor(-2.8) = -3
Floor(2.8) = 2
Floor(-1.0) = -1

Ceil(-2.8) = -2
Ceil(2.8) = 3
Ceil(-1.0) = -1
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2024-5-7 02:00 , Processed in 0.040704 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表