checked in for jerry
[unix-history] / usr / src / usr.bin / f77 / libF77 / zabs.c
CommitLineData
23ec3622 1/*
41ef90cb 2 * @(#)zabs.c 5.2 %G%
23ec3622
KM
3 */
4
41ef90cb 5#ifdef tahoe
23ec3622
KM
6/* THIS IS BASED ON TAHOE FP REPRESENTATION */
7#include <tahoemath/FP.h>
8
9double zabs(real, imag)
10double real, imag;
11{
12double temp, sqrt();
13
14if(real < 0)
15 *(long int *)&real ^= SIGN_BIT;
16if(imag < 0)
17 *(long int *)&imag ^= SIGN_BIT;
18if(imag > real){
19 temp = real;
20 real = imag;
21 imag = temp;
22}
23if(imag == 0.) /* if((real+imag) == real) */
24 return(real);
25
26temp = imag/real;
27temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/
28return(temp);
29}
41ef90cb 30#endif tahoe