C library Macro - EDOM


Advertisements


Description

As mentioned above, the C library macro EDOM represents a domain error, which occurs if an input argument is outside the domain, over which the mathematical function is defined and errno is set to EDOM.

Declaration

Following is the declaration for EDOM Macro.

#define EDOM some_value

Parameters

  • NA

Return Value

  • NA

Example

The following example shows the usage of EDOM Macro.

#include <stdio.h>
#include <errno.h>
#include <math.h>

int main()
{
   double val;

   errno = 0;
   val = sqrt(-10);
   
   if(errno == EDOM) 
   {
      printf("Invalid value \n");
   }
   else 
   {
      printf("Valid value\n");
   }
   
   errno = 0;
   val = sqrt(10);
   
   if(errno == EDOM) 
   {
      printf("Invalid value\n");
   }
   else 
   {
      printf("Valid value\n");
   }
   
   return(0);
}

Let us compile and run the above program that will produce the following result −

Invalid value
Valid value

errorno_h.htm

Advertisements