
- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <float.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdarg.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <time.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C library Macro - ERANGE
Description
As mentioned above, the C library macro ERANGE represents a range error, which occurs if an input argument is outside the range, over which the mathematical function is defined and errno is set to ERANGE.
Declaration
Following is the declaration for ERANGE Macro.
#define ERANGE some_value
Parameters
NA
Return Value
NA
Example
The following example shows the usage of 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) 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; }
Let us compile and run the above program that will produce the following result −
Log(2.000000) = 0.693147 Log(1.000000) = 0.000000 Log(0.000000) is out of range
errorno_h.htm
Advertisements