小白教程
所有教程
关于
Search
172.71.254.194
172.71.254.194
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“C macro erange”的源代码
本页内容
上一节:
C_macro_edom
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:ERANGE Range Error}}[[Category:c standard library errno h|3]] = C 库宏 - ERANGE = [[c standard library errno h|C 标准库 - <errno.h>]] == 描述 == C 库宏 '''ERANGE''' 表示一个范围错误,它在输入参数超出数学函数定义的范围时发生,errno 被设置为 ERANGE。 == 声明 == 下面是 ERANGE 宏的声明。 <pre> #define ERANGE some_value </pre> == 参数 == * '''NA''' == 返回值 == * '''NA''' 下面的实例演示了 ERANGE 宏的用法。 <sample title="" desc="" lang="c" hererun="1"> #include <stdio.h> #include <errno.h> #include <math.h> int main() { double x; double value; x = 2.000000; value = log(x); if( errno == ERANGE ) { printf("Log(%f) is out of range\n", x); } else { printf("Log(%f) = %f\n", x, value); } x = 1.000000; value = log(x); if( errno == ERANGE ) { printf("Log(%f) is out of range\n", x); } else { printf("Log(%f) = %f\n", x, value); } x = 0.000000; value = log(x); if( errno == ERANGE ) { printf("Log(%f) is out of range\n", x); } else { printf("Log(%f) = %f\n", x, value); } return 0; } </sample> 让我们编译并运行上面的程序,这将产生以下结果: <pre> Log(2.000000) = 0.693147 Log(1.000000) = 0.000000 Log(0.000000) = -inf </pre> [[c standard library errno h|C 标准库 - <errno.h>]]
返回至“
C macro erange
”。
上一节:
C_macro_edom