* config.gcc (m32r-elf): Revert previous delta.
[official-gcc.git] / libf2c / libF77 / c_div.c
blobb5ede0eb801fffcd9529c1858ccbbdd68bc8a6e2
1 #include "f2c.h"
3 extern void sig_die (char *, int);
4 void
5 c_div (complex * c, complex * a, complex * b)
7 double ratio, den;
8 double abr, abi, cr;
10 if ((abr = b->r) < 0.)
11 abr = -abr;
12 if ((abi = b->i) < 0.)
13 abi = -abi;
14 if (abr <= abi)
16 if (abi == 0)
18 #ifdef IEEE_COMPLEX_DIVIDE
19 float af, bf;
20 af = bf = abr;
21 if (a->i != 0 || a->r != 0)
22 af = 1.;
23 c->i = c->r = af / bf;
24 return;
25 #else
26 sig_die ("complex division by zero", 1);
27 #endif
29 ratio = (double) b->r / b->i;
30 den = b->i * (1 + ratio * ratio);
31 cr = (a->r * ratio + a->i) / den;
32 c->i = (a->i * ratio - a->r) / den;
35 else
37 ratio = (double) b->i / b->r;
38 den = b->r * (1 + ratio * ratio);
39 cr = (a->r + a->i * ratio) / den;
40 c->i = (a->i - a->r * ratio) / den;
42 c->r = cr;