abs method
Computes the square root of (a2 + b2) where a
is the real part and b
is the imaginary part.
This is is the modulus/magnitude/absolute value of the complex number.
Implementation
double abs() {
if ((real != 0) || (imaginary != 0)) {
return math.sqrt(real * real + imaginary * imaginary);
}
return 0;
}