钓鱼用八爪鱼钩好用吗:round函数

来源:百度文库 编辑:九乡新闻网 时间:2024/03/28 21:49:00

Excel 中的 round 函数

  Round 函数  返回按指定位数进行四舍五入的数值。  Round(expression, numdecimalplaces)

参数

  Expression  必选项。数值表达式 被四舍五入。  Numdecimalplaces  可选项。数字表明小数点右边有多少位进行四舍五入。如果小数位数是负数,则round()返回的结果在小数点左端包含指定个零.如果省略,则 Round 函数返回整数。

更详细的解释及举例

  利用INT函数构造四舍五入的函数返回的结果精度有限,有时候满足不了我们的实际需要。Excel的Round函数可以解决这个问题。Round函数的作用是返回某个数字按指定位数取整后的数字。语法为ROUND(number,num_digits),其中Number是需要进行四舍五入的数字;Num_digits为指定的位数,按此位数进行四舍五入,如果 num_digits 大于 0,则四舍五入到指定的小数位,如果 num_digits 等于 0,则四舍五入到最接近的整数,如果 num_digits 小于 0,则在小数点左侧进行四舍五入。 举例来说, =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。

操作方法

  创建空白工作簿或工作表。  请在“帮助”主题中选取示例。不要选取行或列标题。  从帮助中选取示例。  按 Ctrl+C。  在工作表中,选中单元格 A1,再按 Ctrl+V。  若要在查看结果和查看返回结果的公式之间切换,请按 Ctrl+`(重音符),或在“工具”菜单上,指向“公式审核”,再单击“公式审核模式”。  1  2  3  4  5  A B  公式 说明(结果)  =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)

编辑本段C 语言中的 round() 函数

  Function: round roundf roundl  Synopsis  #include 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   #include   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  [1]