打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
round函数编辑词条

Round 函数

  返回按指定位数进行四舍五入的数值。

  ROUND(number, num_digits)

参数

  number 必需。要四舍五入的数字。

  num_digits 必需。位数,按此位数对 number 参数进行四舍五入。

更详细的解释说明

  利用INT函数构造四舍五入的函数返回的结果精度有限,有时候满足不了我们的实际需要。Excel的Round函数可以解决这个问题。

  ROUND函数中:

  如果 num_digits 大于 0(零),则将数字四舍五入到指定的小数位。

  如果 num_digits 等于 0,则将数字四舍五入到最接近的整数。

  如果 num_digits 小于 0,则在小数点左侧进行四舍五入。

  若要始终进行向上舍入(远离 0),请使用 ROUNDUP 函数。

  若要始终进行向下舍入(朝向 0),请使用 ROUNDDOWN 函数。

  若要将某个数字四舍五入为指定的倍数(例如,四舍五入为最接近的 0.5 倍),请使用 MROUND 函数。

实例

ROUND(2.15, 1)将 2.15 四舍五入到一个小数位2.2
=ROUND(2.149, 1)将 2.149 四舍五入到一个小数位2.1
=ROUND(-1.475, 2)将 -1.475 四舍五入到两个小数位-1.48
=ROUND(21.5, -1)将 21.5 四舍五入到小数点左侧一位20
 

  Function: round roundf roundl

  Synopsis  

  #include <math.h>long double roundl(long double x);double round(double x);float roundf(float x);Description  

  The round functions will return a rounded integer in the specified format that will be rounded to the nearest integer regardless of the current rounding mode.

  Returns  

  The rounded value.

  例子:

  ceil(x)返回不小于x的最小整数值(然后转换为double型)。

  floor(x)返回不大于x的最大整数值。

  round(x)返回x的四舍五入整数值。

  #include <stdio.h>

  #include <math.h>

  int main(int argc, const char *argv[])

  {

  float num = 1.4999;

  printf("ceil(%f) is %f\n", num, ceil(num));

  printf("floor(%f) is %f\n", num, floor(num));

  printf("round(%f) is %f\n", num, round(num));

  return 0;

  }

  编译:$cc test.c -lm

  执行:$./a.out

  ceil(1.499900) is 2.000000

  floor(1.499900) is 1.000000

  round(1.499900) is 1.000000 

函数功能:

  四舍五入取整

使用方法:

  B = round(A)   

  对数组A中每个元素朝最近的方向取整数部分,并返回与A同维的整数数组B,对于一个复数参量A,则分别对其实部和虚数朝最近的方向取整数部分,并返回一复数数据B。

应用举例:

  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

  Columns 5 through 6

  7.0000 2.4000 + 3.6000i

  round(a)

  ans =

  Columns 1 through 4

  -2.0000 0 3.0000 6.0000

  Columns 5 through 6

  7.0000 2.0000 + 4.0000i

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
round函数
delphi的取整函数round、trunc、ceil和floor
JS生成随机数(random()函数)
PHP四舍五入精确小数位及取整
EXCEL技巧六十三:round函数的使用方法和实例
javascript中的Math.random()用法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服