Domain and Range Errors






Domain and Range Errors

A domain error occurs when a function is not defined for its input argument value or values. A range error occurs when the return value of a function is defined but cannot be represented. The headers <math.h> and <cmath> define several macros for error handling.

#define MATH_ERRNO 1
#define MATH_ERREXCEPT 2
#define math_errhandling < int rvalue >

The value of the macro math_errhandling doesn't change during program execution. As its name suggests, it gives you information about how math errors are handled in library functions.

  • If (math_errhandling & MATH_ERRNO) != 0, a math function stores a nonzero value in errno and returns a particular value that characterizes the error.

  • If (math_errhandling & MATH_ERREXCEPT) != 0, a math function raises an invalid floating-point exception (Section 12.3.4). In this case, the macros FE_INVALID, FE_OVERFLOW and FE_DIVBYZERO are all defined.

#define HUGE_VAL <double rvalue>
#define HUGE_VALF <float rvalue>
#define HUGE_VALL <long double rvalue>

The macros HUGE_VAL, HUGE_VALF, and HUGE_VALL yield values of type double, float, and long double, respectively, returned by some functions on a range error. The values can be representations of infinity.



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows