You copied the Doc URL to your clipboard.

mathlib error handling

In ARM Compiler 4.1 and later, the error handling of mathematical functions is consistent with Annex F of the ISO/IEC C99 standard. In RVCT 4.0 and earlier, it is not.

To invoke RVCT 4.0 and earlier behavior, you can define __use_rvct_matherr. The following table shows how the math functions respond when supplied with out-of-range arguments.

Table 1-10 Mathematical functions in RVCT 4.0 and earlier

Function Condition Returned value Error number
acos(x) abs(x) > 1 QNaN EDOM
asin(x) abs(x) > 1 QNaN EDOM
atan2(x,y) x = 0, y = 0 QNaN EDOM
atan2(x,y) x = Inf, y = Inf QNaN EDOM
cos(x) x = Inf QNaN EDOM
cosh(x) Overflow +Inf ERANGE
exp(x) Overflow +Inf ERANGE
exp(x) Underflow +0 ERANGE
fmod(x,y) x = Inf QNaN EDOM
fmod(x,y) y = 0 QNaN EDOM
log(x) x < 0 QNaN EDOM
log(x) x = 0 -Inf EDOM
log10(x) x < 0 QNaN EDOM
log10(x) x = 0 -Inf EDOM
pow(x,y) Overflow +Inf ERANGE
pow(x,y) Underflow 0 ERANGE
pow(x,y) x = 0 or x = Inf, y = 0 +1 EDOM
pow(x,y) x = +0, y < 0 -Inf EDOM
pow(x,y) x = -0, y < 0 and y integer -Inf EDOM
pow(x,y) x = -0, y < 0 and y non-integer QNaN EDOM
pow(x,y) x < 0, y non-integer QNaN EDOM
pow(x,y) x = 1, y = Inf QNaN EDOM
sqrt(x) x < 0 QNaN EDOM
sin(x) x = Inf QNaN EDOM
sinh(x) Overflow +Inf ERANGE
tan(x) x = Inf QNaN EDOM
atan(x) SNaN SNaN None
ceil(x) SNaN SNaN None
floor(x) SNaN SNaN None
frexp(x) SNaN SNaN None
ldexp(x) SNaN SNaN None
modf(x) SNaN SNaN None
tanh(x) SNaN SNaN None

HUGE_VAL is an alias for Inf. Consult the errno variable for the error number. Other than the cases shown in this table, all functions return QNaN when passed QNaN and throw an invalid operation exception when passed SNaN.

The string passed to C99 nan() is ignored, and the same Not a Number (NaN) is always returned, namely the one with all fraction bits clear except the topmost one. The sign bit is also clear. Passing strings of the form NAN(xxxx) to strtod has the same effect.