English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C Standard Library - <errno.h>
C Library Macro ERANGE Indicates a range error that occurs when the input parameter is out of the range defined by the mathematical function, and errno is set to ERANGE.
The following is the declaration of the ERANGE macro.
#define ERANGE some_value
NA
NA
The following example demonstrates the usage of the ERANGE macro.
#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) 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) 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) out of range\n", x); } else { printf("Log(%f) = %f\n", x, value); } return 0; }
Let's compile and run the above program, which will produce the following result:
Log(2.000000) = 0.693147 Log(1.000000) = 0.000000 Log(0.000000) = -inf