ERANGE – C语言宏
C库宏ERANGE表示范围错误发生,如果输入参数范围以外的数学函数定义和errno设置为ERANGE。
声明
以下是声明宏ERANGE。
#define ERANGE some_value
参数
-
NA
返回值
-
NA
例子
下面的例子演示了如何使用宏ERANGE。
#include<stdio.h>#include<errno.h>#include<math.h>int main(){double x;double value; x =1.000000; value = log(x);if( errno == ERANGE ){ printf("Log(%f) is out of range ", x);}else{ printf("Log(%f) = %f ", x, value);} x =0.000000; value = log(x);if( errno == ERANGE ){ printf("Log(%f) is out of range " x);}else{ printf("Log(%f) = %f ", x, value);}return0;}
让我们编译和运行上面的程序,这将产生以下结果:
Log(1.000000) = 1.609438 Log(0.000000) is out of range