Returns the absolute value of the complex number.
()
| 175 | * Returns the absolute value of the complex number. |
| 176 | */ |
| 177 | public double abs() { |
| 178 | double absRe = Math.abs(re); |
| 179 | double absIm = Math.abs(im); |
| 180 | if((absRe==0)&&(absIm==0)) { |
| 181 | return 0; |
| 182 | } else if(absRe>absIm) { |
| 183 | double temp = absIm/absRe; |
| 184 | return absRe*Math.sqrt(1+temp*temp); |
| 185 | } else { |
| 186 | double temp = absRe/absIm; |
| 187 | return absIm*Math.sqrt(1+temp*temp); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 |