Pristine Ack-5.5
[Ack-5.5.git] / mach / proto / fp / fif4.c
1 /*
2   (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3   See the copyright notice in the ACK home directory, in the file "Copyright".
4 */
5
6 /* $Id: fif4.c,v 1.9 1994/06/24 13:32:07 ceriel Exp $ */
7
8 /*
9         MULTIPLY AND DISMEMBER PARTS (FIF 4)
10 */
11
12 #include "FP_types.h"
13 #include "FP_shift.h"
14
15 void
16 fif4(p,x,y)
17 SINGLE  x,y;
18 struct fif4_returns *p;
19 {
20
21         EXTEND  e1,e2;
22
23         extend(&y,&e1,sizeof(SINGLE));
24         extend(&x,&e2,sizeof(SINGLE));
25                 /* do a multiply */
26         mul_ext(&e1,&e2);
27         e2 = e1;
28         compact(&e2,&y,sizeof(SINGLE));
29         if (e1.exp < 0) {
30                 p->ipart = 0;
31                 p->fpart = y;
32                 return;
33         }
34         if (e1.exp > 30 - SGL_M1LEFT) {
35                 p->ipart = y;
36                 p->fpart = 0;
37                 return;
38         }
39         b64_sft(&e1.mantissa, 63 - e1.exp);
40         b64_sft(&e1.mantissa, e1.exp - 63);     /* "loose" low order bits */
41         compact(&e1,&(p->ipart),sizeof(SINGLE));
42         extend(&(p->ipart), &e2, sizeof(SINGLE));
43         extend(&y, &e1, sizeof(SINGLE));
44         sub_ext(&e1, &e2);
45         compact(&e1, &(p->fpart), sizeof(SINGLE));
46 }