1989-07-10 11:17:19 +00:00
|
|
|
/*
|
|
|
|
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Header$ */
|
|
|
|
|
|
|
|
#include "misc.h"
|
|
|
|
#include <em_arith.h>
|
|
|
|
|
1989-11-27 17:25:55 +00:00
|
|
|
flt_arith2flt(n, e, uns)
|
1989-07-10 11:17:19 +00:00
|
|
|
register arith n;
|
|
|
|
register flt_arith *e;
|
|
|
|
{
|
|
|
|
/* Convert the arith "n" to a flt_arith "e".
|
|
|
|
*/
|
|
|
|
register int i;
|
|
|
|
|
1989-11-27 17:25:55 +00:00
|
|
|
if (!uns && n < 0) {
|
1989-07-10 11:17:19 +00:00
|
|
|
e->flt_sign = 1;
|
|
|
|
n = -n;
|
|
|
|
}
|
|
|
|
else e->flt_sign = 0;
|
|
|
|
e->m1 = e->m2 = 0;
|
1989-10-19 14:50:52 +00:00
|
|
|
if (n == 0) {
|
|
|
|
e->flt_exp = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
e->flt_exp = 63;
|
1989-11-27 17:25:55 +00:00
|
|
|
|
1989-07-10 11:17:19 +00:00
|
|
|
for (i = 64; i > 0 && n != 0; i--) {
|
1989-10-16 17:56:36 +00:00
|
|
|
flt_b64_sft(&(e->flt_mantissa),1);
|
1989-07-10 11:17:19 +00:00
|
|
|
e->m1 |= (n & 1) << 31;
|
1989-11-27 17:25:55 +00:00
|
|
|
n = (n >> 1) & ~(0x80 << 8*(sizeof(arith)-1));
|
1989-07-10 11:17:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (i > 0) {
|
1989-07-11 09:15:17 +00:00
|
|
|
flt_b64_sft(&(e->flt_mantissa), i);
|
1989-07-10 11:17:19 +00:00
|
|
|
}
|
|
|
|
flt_status = 0;
|
|
|
|
flt_nrm(e);
|
|
|
|
}
|