[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
EXCEL中对数字的处理中,经常根据需要按指定的位数进行取整。
数字取整可以用下述函数完成:
四舍五入取整 =ROUND(A1,0)
截去小数取整=ROUNDDOWN(A1,0) =FLOOR(A1,1) =TRUNC(A1)
截去小数取整为最接近的偶数 =EVEN(A1)
截去小数向上取整数 =CEILING(A1,1)
截去小数向下取整 =INT(A1)
C语言有以下几种取整方法:
1、直接赋值给整数变量。如:
int i = 2.5; 或 i = (int) 2.5;
这种方法采用的是舍去小数部分
2、C/C++中的整数除法运算符“/”本身就有取整功能(int / int),但是整数除法对负数的取整结果和使用的C编译器有关。
3、使用floor函数。floor(x)返回的是小于或等于x的最大整数。如:
floor(2.5) = 2
floor(-2.5) = -3
4、使用ceil函数。ceil(x)返回的是大于x的最小整数。如:
ceil(2.5) = 3
ceil(-2.5) = -2
floor()是向负无穷大舍入,floor(-2.5) = -3;ceil()是向正无穷大舍入,ceil(-2.5) = -2。
MATLAB中的取整函数很多,为方便以后使用把其用法列出来:
floor
B = floor(A) 返回小于或等于A的整数值,对于复数来说,分别对A的实部和虚部进行运算。
a = [-1.9, -0.2, 3.4, 5.6, 7.0, 2.4+3.6i]
a =
Columns 1 through 6
-1.9000 -0.2000 3.4000 5.6000 7.0000 2.4000 + 3.6000i
floor(a)
ans =
Columns 1 through 6
-2.0000 -1.0000 3.0000 5.0000 7.0000 2.0000 + 3.0000i
ceil
B = ceil(A) 返回大于或等于A的整数值,对于复数来说,分别对A的实部和虚部进行运算。
a = [-1.9, -0.2, 3.4, 5.6, 7, 2.4+3.6i]
a =
Columns 1 through 6
-1.9000 -0.2000 3.4000 5.6000 7.0000 2.4000 + 3.6000i
ceil(a)
ans =
Columns 1 through 6
-1.0000 0 4.0000 6.0000 7.0000 3.0000 + 4.0000i
round:
Y = round(X) 返回距离X最近的整数值。
a = [-1.9, -0.2, 3.4, 5.6, 7.0, 2.4+3.6i]
a =
Columns 1 through 4
-1.9000 -0.2000 3.4000 5.6000 7.0000 2.4000 + 3.6000i
round(a)
ans =
Columns 1 through 4
-2.0000 0 3.0000 6.0000 7.0000 2.0000 + 4.0000i
fix:
B = fix(A) 返回A的整数部分,小数部分为0
a = [-1.9, -0.2, 3.4, 5.6, 7.0, 2.4+3.6i]
a =
Columns 1 through 4
-1.9000 -0.2000 3.4000 5.6000 7.0000 2.4000 + 3.6000i
fix(a)
ans =
Columns 1 through 4
-1.0000 0 3.0000 5.0000 7.0000 2.0000 + 3.0000i