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".
|
|
|
|
*/
|
|
|
|
|
1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1989-07-10 11:17:19 +00:00
|
|
|
|
1991-02-19 13:53:04 +00:00
|
|
|
#include "flt_misc.h"
|
1989-07-10 11:17:19 +00:00
|
|
|
#include <em_arith.h>
|
|
|
|
|
2019-05-10 16:56:13 +00:00
|
|
|
void flt_arith2flt(arith n, flt_arith *e, int uns)
|
1989-07-10 11:17:19 +00:00
|
|
|
{
|
|
|
|
/* Convert the arith "n" to a flt_arith "e".
|
|
|
|
*/
|
|
|
|
|
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;
|
1991-03-11 14:38:28 +00:00
|
|
|
if (sizeof(arith) == 4) {
|
1991-10-02 15:20:22 +00:00
|
|
|
e->m1 = 0; e->m2 = n;
|
1991-06-26 17:26:59 +00:00
|
|
|
}
|
|
|
|
else {
|
Convert 1 to 1.0, not 0.0, for machines with 64-bit long.
This fixes flt_arith2flt() when sizeof(arith) != 4, where arith is
long. When cemcom.ansi sees an expression like d + 1 (where d is some
double), it calls flt_arith2flt() to convert 1 to floating-point. On
machines where sizeof(arith) != 4, the code did n >>= 1 when n should
not have been changed. If n was 1, then n == 0 became true. This
caused the code to convert 1 or -1 to 0.0.
My fix assumes sizeof(arith) >= 8, so I can use n >> 32. Machines
with sizeof(arith) of 5 to 7 would need to do (uarith)n >> 32, where
uarith must be an unsigned integer type of same size as arith.
In startrek.c, the Enterprise can now dock with a starbase. The
compiler no longer translates s1 - 1 to s1 - 0.0 and s1 + 1 to s1 +
0.0, so the game now looks for starbases next to the Enterprise.
2016-11-07 00:34:51 +00:00
|
|
|
/* assuming sizeof(arith) >= 8 */
|
|
|
|
e->m1 = n >> 32;
|
|
|
|
e->m2 = n;
|
1991-02-26 15:46:18 +00:00
|
|
|
}
|
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
|
|
|
flt_status = 0;
|
|
|
|
flt_nrm(e);
|
|
|
|
}
|