词条 | round函数 |
释义 | 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 <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\", num, ceil(num)); printf("floor(%f) is %f\", num, floor(num)); printf("round(%f) is %f\", 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 Matlab中round函数函数功能:四舍五入取整 使用方法: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 |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。