Wiki Markup |
---|
C99 Section 7.12.1 defines two types of errors that relate specifically to math functions in {{math.h}} \[[ISO/IEC 9899-:1999|AA. C References#ISO/IEC 9899-1999]\]: |
...
An example of a domain error is the square root of a negative number, such as sqrt(-1.0)
, which has no meaning in real arithmetic. Similarly, ten raised to the one-millionth power, pow(10., 1e6)
, likely cannot be represented in an implementation's floating point representation and therefore consequently constitutes a range error.
...
Wiki Markup |
---|
The exact treatment of error conditions from math functions is quite complicated. C99 Section 7.12.1 defines the following behavior for floating point overflow \[[ISO/IEC 9899-:1999|AA. C References#ISO/IEC 9899-1999]\] |
...
Wiki Markup |
---|
It is also difficult to check for math errors using {{errno}} because an implementation might not set it. For real functions, the programmer can tell whether the implementation sets {{errno}} by checking whether {{math_errhandling & MATH_ERRNO}} is nonzero. For complex functions, the C99 Section 7.3.2 simply states "an implementation may set {{errno}} but is not required to" \[[ISO/IEC 9899-:1999|AA. C References#ISO/IEC 9899-1999]\]. |
...
Wiki Markup |
---|
\[[ISO/IEC 9899-:1999|AA. C References#ISO/IEC 9899-1999]\] Section 7.3, "Complex arithmetic <complex.h>", and Section 7.12, "Mathematics <math.h>" \[[Plum 85|AA. C References#Plum 85]\] Rule 2-2 \[[Plum 89|AA. C References#Plum 91]\] Topic 2.10, "conv - conversions and overflow" |
...