**********************************************************
Frank van Eeken [eeken@q-ray.nl]
**********************************************************
I was looking at the function rounding. Once I had to make a Round-function and
I made exactly the same function as you showed on your VB-page.
But this one isn't working properly. (reference: VB 09-05-97)
See the example below:
Round(2.15,1) = 2.2 OK
Round(1.15,1) = 1.1 Not OK
The type declaration of the parameter X should be changed from Double to Variant.
Function Round (X as Variant, DP as integer) as Double
Round = Int((X * 10 ^ DP) + 0.5) / 10 ^ DP
End Function
Frank van Eeken
Internet: http://www.q-ray.nl, http://www.agriplus.nl
**********************************************************
Faraz Khan [Faraz.Khan@asu.edu]
**********************************************************
Use the following:
Function Round (X as Double, DP as integer) as Double
Round = Int((X * 10 ^ DP) + 0.5) / 10 ^ DP
End Function
where DP is the decimal place to round to (0 to 14) e.g
Round (3.56376, 3) will give the result 3.564
Round (3.56376, 1) will give the result 3.6
Round (3.56376, 0) will give the result 4
Round (3.56376, 2) will give the result 3.56
Round (1.4999, 3) will give the result 1.5
Round (1.4899, 2) will give the result 1.49
*****************************************************************
Geoff Stirling: Montreal, PQ, Canada
*****************************************************************
How to round a number to the nearest value of 5.
12.4 + 2.5 = 14.9 \5 = 2 * 5 = 10
12.6 + 2.5 = 15.1\5 = 3 * 5 = 15
18.1 + 2.5 = 20.6\5 = 4 * 5 =20
Note the case of 12.5 (12.5 + 2.5 = 15\5 = 3 * 5 = 15). This rounds
up from the midpoint. If you want to round down at the midpoint, you
might have to use 2.49 or 2.499 etc depending on the precision of your
data.
没有合适的资源?快使用搜索试试~ 我知道了~
取整数的几种方法.7z
共1个文件
txt:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 113 浏览量
2023-06-18
11:36:32
上传
评论
收藏 995B 7Z 举报
温馨提示
取整数的几种方法.7z
资源推荐
资源详情
资源评论
收起资源包目录
取整数的几种方法.7z (1个子文件)
取整数的几种方法
vbroundingnumbers.txt 2KB
共 1 条
- 1
资源评论
应用市场
- 粉丝: 456
- 资源: 3808
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功