楼主: Nelsh--Deng
14751 10

[问答] round函数 [推广有奖]

  • 13关注
  • 7粉丝

学科带头人

45%

还不是VIP/贵宾

-

威望
0
论坛币
9376 个
通用积分
4.2428
学术水平
13 点
热心指数
14 点
信用等级
11 点
经验
49840 点
帖子
1009
精华
0
在线时间
2785 小时
注册时间
2012-12-21
最后登录
2025-9-23

楼主
Nelsh--Deng 发表于 2015-7-27 16:26:56 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请问round函数是什么意思,谢谢了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:ROUND und 是什么意思

沙发
洁宝宝记得幸福 发表于 2015-7-27 16:30:57
四舍五入函数
已有 1 人评分论坛币 收起 理由
admin_kefu + 5 热心帮助其他会员

总评分: 论坛币 + 5   查看全部评分

藤椅
chonghuihedong 发表于 2015-7-27 16:37:08
进来看看

板凳
Nelsh--Deng 发表于 2015-7-27 17:27:15
洁宝宝记得幸福 发表于 2015-7-27 16:30
四舍五入函数
怎么个舍法怎么个如法,请大神能不能说清楚,为什么有时候四舍五入,有时候五也舍去呢

报纸
飞行员 发表于 2015-7-27 23:04:20
Nelsh--Deng 发表于 2015-7-27 17:27
怎么个舍法怎么个如法,请大神能不能说清楚,为什么有时候四舍五入,有时候五也舍去呢
是不是四舍六入五成双?以前学分析化学的时候用的规则

地板
Nelsh--Deng 发表于 2015-7-27 23:24:56
飞行员 发表于 2015-7-27 23:04
是不是四舍六入五成双?以前学分析化学的时候用的规则
这个还真不知道

7
Nelsh--Deng 发表于 2015-7-27 23:25:41
飞行员 发表于 2015-7-27 23:04
是不是四舍六入五成双?以前学分析化学的时候用的规则
博学,不错

8
USitachi 发表于 2016-11-3 14:00:34
66666666

9
llulla 发表于 2016-11-3 14:32:07
Both round() and signif() round numbers to the nearest possibility. So, if the first digit that’s dropped is smaller than 5, the number is rounded down. If it’s bigger than 5, the number is rounded up.

If the first digit that is dropped is exactly 5, R uses a rule that’s common in programming languages: Always round to the nearest even number. round(1.5) and round(2.5) both return 2, for example, and round(-4.5) returns -4.

Contrary to round(), three other functions always round in the same direction:

floor(x) rounds to the nearest integer that’s smaller than x. So floor(123.45) becomes 123 and floor(-123.45) becomes –124.

ceiling(x) rounds to the nearest integer that’s larger than x. This means ceiling (123.45) becomes 124 and ceiling(123.45) becomes –123.

trunc(x) rounds to the nearest integer in the direction of 0. So trunc(123.65) becomes 123 and trunc(-123.65) becomes –123.

已有 1 人评分论坛币 学术水平 热心指数 收起 理由
admin_kefu + 30 + 2 + 2 热心帮助其他会员

总评分: 论坛币 + 30  学术水平 + 2  热心指数 + 2   查看全部评分

10
llulla 发表于 2016-11-3 14:33:14


Note that for rounding off a 5, the IEC 60559 standard is expected to be used, ‘go to the even digit’. Therefore round(0.5) is 0 and round(-1.5) is -2. However, this is dependent on OS services and on representation error (since e.g. 0.15 is not represented exactly, the rounding rule applies to the represented number and not to the printed number, and so round(0.15, 1) could be either 0.1 or 0.2).

Rounding to a negative number of digits means rounding to a power of ten, so for example round(x, digits = -2) rounds to the nearest hundred.

For signif the recognized values of digits are 1...22, and non-missing values are rounded to the nearest integer in that range. Complex numbers are rounded to retain the specified number of digits in the larger of the components. Each element of the vector is rounded individually, unlike printing.

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 11:34