atan2, atan2f, atan2l
From cppreference.com
Defined in header <math.h>
|
||
float atan2f( float y, float x ); |
(1) | (since C99) |
double atan2( double y, double x ); |
(2) | |
long double atan2l( long double y, long double x ); |
(3) | (since C99) |
Defined in header <tgmath.h>
|
||
#define atan2( arg ) |
(4) | (since C99) |
1-3) Computes the arc tangent of
y/x
using the signs of arguments to determine the correct quadrant.4) Type-generic macro: If the argument has type long double,
atan2l
is called. Otherwise, if the argument has integer type or the type double, atan2
is called. Otherwise, atan2f
is called.Parameters
x, y | - | floating point value |
Return value
If no errors occur, the arc tangent ofy/x
(arctan(y |
x |
If a domain error occurs, an implementation-defined value is returned.
If a range error occurs due to underflow, the correct result (after rounding) is returned.
Error handling
Errors are reported as specified in math_errhandling.
Domain error may occur if x
and y
are both zero.
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
- If
x
andy
are both zero, domain error does not occur - If
x
andy
are both zero, range error does not occur either - If
y
is zero, pole error does not occur - If
y
is±0
andx
is negative or-0
,±π
is returned - If
y
is±0
andx
is positive or+0
,±0
is returned - If
y
is±∞
andx
is finite,±π/2
is returned - If
y
is±∞
andx
is-∞
,±3π/4
is returned - If
y
is±∞
andx
is+∞
,±π/4
is returned - If
x
is±0
andy
is negative,-π/2
is returned - If
x
is±0
andy
is positive,+π/2
is returned - If
x
is-∞
andy
is finite and positive,+π
is returned - If
x
is-∞
andy
is finite and negative,-π
is returned - If
x
is+∞
andy
is finite and positive,+0
is returned - If
x
is+∞
andy
is finite and negative,-0
is returned - If either
x
is NaN ory
is NaN, NaN is returned
Notes
atan2(y, x) is equivalent to carg(x + I*y).
POSIX specifies that in case of underflow, y/x
is the value returned, and if that is not supported, an implementation-defined value no greater than DBL_MIN, FLT_MIN, and LDBL_MIN is returned.