Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Math errors can be prevented by carefully bounds-checking the arguments before calling functions. In particular, the following domain errors functions should be prevented by prior bounds-checkingbounds checked as follows:

Function

Bounds-checking

acos( x ), asin( x )

-1 <= x && x <= 1

atan2( y, x )

x != 0 || y != 0

log( x ), log10( x )

x >= 0

pow( x, y )

x != 0 || y > 0

sqrt( x )

x >= 0

...