Easy Tutorial
❮ C Function Localtime C Function Putchar ❯

C Library Macro - EDOM

C Standard Library - <errno.h>

Description

The C library macro EDOM represents a domain error, which occurs when an input parameter is outside the domain over which a mathematical function is defined, and errno is set to EDOM.

Declaration

Here is the declaration for the EDOM macro.

#define EDOM some_value

Parameters

Return Value

Example

The following example demonstrates the use of the 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's compile and run the above program, which will produce the following result:

Invalid value
Valid value

C Standard Library - <errno.h>

❮ C Function Localtime C Function Putchar ❯