Pristine Ack-5.5
[Ack-5.5.git] / modules / src / flt_arith / flt_ar2flt.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: flt_ar2flt.c,v 1.14 1994/06/24 11:15:37 ceriel Exp $ */
7
8 #include "flt_misc.h"
9 #include <em_arith.h>
10
11 void
12 flt_arith2flt(n, e, uns)
13         register arith n;
14         register flt_arith *e;
15 {
16         /*      Convert the arith "n" to a flt_arith "e".
17         */
18
19         if (!uns && n < 0) {
20                 e->flt_sign = 1;
21                 n = -n;
22         }
23         else    e->flt_sign = 0;
24         if (sizeof(arith) == 4) {
25                 e->m1 = 0; e->m2 = n;
26         }
27         else {
28                 e->m2 = n & 0xffffffffL;
29                 n >>= 1;
30                 n &= ~((arith) 1 << (8*sizeof(arith)-1));
31                 e->m1 = (n >> 31);
32         }
33         if (n == 0) {
34                 e->flt_exp = 0;
35                 return;
36         }
37         e->flt_exp = 63;
38                 
39         flt_status = 0;
40         flt_nrm(e);
41 }