...
Function | Bounds-checking |
---|---|
acos(x), asin(x) | -1 <= x && x <= 1 |
atan2 | x != 0 || y != 0 |
log, log10 | x >= 0 |
pow(x, y) | x != 0 || y > 0 |
sqrt (x) | x >= 0 |
The calling function should take alternative action if these bounds are violated.
...
Code Block |
---|
float x, y, result; if( x == 0 && y == 0){ /* handle domain error */ } result = atan2(y, x); |
log, log10
Non-Compliant Example
Code Block |
---|
Compliant Example
Code Block |
---|
pow(x,y)
Non-Compliant Example
The following code may produce a domain error if x is zero and y less than or equal to zero. A range error may also occur if x is zero and y is negative.
...