#define sqrt( z )
(4) (since C99)1-3) Computes the complex square root of z
with branch cut along the negative real axis.
Type-generic macro: If
z
has type
long double complex,
csqrtl
is called. if
z
has type
double complex,
csqrt
is called, if
z
has type
float complex,
csqrtf
is called. If
z
is real or integer, then the macro invokes the corresponding real function (
sqrtf,
sqrt,
sqrtl). If
z
is imaginary, the corresponding complex number version is called.
[edit] Parameters [edit] Return valueIf no errors occur, returns the square root of z
, in the range of the right half-plane, including the imaginary axis ([0; +â) along the real axis and (ââ; +â) along the imaginary axis.)
Errors are reported consistent with math_errhandling
If the implementation supports IEEE floating-point arithmetic,
z
is ±0+0i
, the result is +0+0i
z
is x+âi
, the result is +â+âi
even if x is NaNz
is x+NaNi
, the result is NaN+NaNi
(unless x is 屉) and FE_INVALID may be raisedz
is -â+yi
, the result is +0+âi
for finite positive yz
is +â+yi
, the result is +â+0i)
for finite positive yz
is -â+NaNi
, the result is NaN屉i
(sign of imaginary part unspecified)z
is +â+NaNi
, the result is +â+NaNi
z
is NaN+yi
, the result is NaN+NaNi
and FE_INVALID may be raisedz
is NaN+NaNi
, the result is NaN+NaNi
#include <stdio.h> #include <complex.h> int main(void) { double complex z1 = csqrt(-4); printf("Square root of -4 is %.1f%+.1fi\n", creal(z1), cimag(z1)); double complex z2 = csqrt(conj(-4)); // or, in C11, CMPLX(-4, -0.0) printf("Square root of -4-0i, the other side of the cut, is " "%.1f%+.1fi\n", creal(z2), cimag(z2)); }
Output:
Square root of -4 is 0.0+2.0i Square root of -4-0i, the other side of the cut, is 0.0-2.0i[edit] References
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4