| | |
EDOM: Domain Error
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
For all functions, a domain error occurs if an input argument is outside the domain over which the mathematical function is defined. On a domain error, the function returns an implementation-defined value.
#include <stdio.h> #include <errno.h> #include <math.h> #define POSITIVE 25 #define NEGATIVE -25 int main() { double ret; errno = 0; ret = sqrt(NEGATIVE); if (errno == EDOM) /*EDOM Signifies Domain Error*/ printf("Domain Error : Invalid Input To Function\n"); else printf("Valid Input To Function\n"); errno = 0; ret = sqrt(POSITIVE); if (errno == EDOM) printf("Domain Error : Invalid Input To Function\n"); else printf("Valid Input To Function\n"); return 0; } /*** * Output * Domain Error:Invalid Input To Function * Valid Input To Function ***/
0
•
•
•
•
Consider also using
perror to diagnose the problem.#include <stdio.h>
#include <errno.h>
#include <math.h>
void test(double value)
{
double ret;
errno = 0;
ret = sqrt(value);
if ( errno )
{
perror("sqrt");
}
else
{
printf("ret = %g\n", ret);
}
}
int main()
{
test(-25);
test(25);
}
/* my output
sqrt: Domain error
ret = 5
*/ Similar Threads
- Domain Error Logging into New Windows XP Home Edition installation (Windows NT / 2000 / XP)
- Problems joining ADS Domain , Cross Domain Autentication, likewise (*nix Software)
- Domain Bangladesh is providing BD Domain in cheap rate than other domain register com (Website Reviews)
- fetching Unique URL, Domain name and sub domain names from Web Page (Python)
- pow: DOMAIN error (C++)
| Thread Tools | Search this Thread |
adobe ansi api array arrays asterisks binarysearch calculate centimeter char convert copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory dynamic fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop initialization interest kernel km linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix power probleminc program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming stack standard string strings structures systemcall testautomation turboc unix user variable voidmain() wab win32api windows.h



