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".
9 CONVERT FLOAT TO SIGNED (CFI m n)
11 N.B. The caller must know what it is getting.
12 A LONG is always returned. If it is an
13 integer the high byte is cleared first.
22 int ds
; /* destination size (2 or 4) */
23 int ss
; /* source size (4 or 8) */
24 DOUBLE src
; /* assume worst case */
30 extend(&src
.d
[0],&buf
,ss
); /* get extended format */
31 if (buf
.exp
< 0) { /* no conversion needed */
35 max_exp
= (ds
<< 3) - 2; /* signed numbers */
36 /* have more limited max_exp */
37 if (buf
.exp
> max_exp
) {
38 if (buf
.exp
== max_exp
+1 && buf
.sign
&& buf
.m1
== NORMBIT
&&
42 trap(EIOVFL
); /* integer overflow */
43 buf
.exp
%= max_exp
; /* truncate */
46 new = buf
.m1
>> (31-buf
.exp
);