ack/modules/src/flt_arith/b64_add.c
George Koehler daeeb5aca3 Simplify flt_arith now that mantissa uses uint32_t.
It seems that someone wanted to build flt_arith with a compiler that
had long but not unsigned long.  This required extra code to
accomplish unsigned right shift, unsigned division, and unsigned
comparison using the signed operations.  Now that we use uint32_t, we
can simply use the unsigned operations and remove the ucmp() function.
We have similar code in mach/proto/fp/ and in
lang/cem/libcc.ansi/stdlib/ext_comp.c where we use the unsigned
operations.

Some long variables become uint32_t, and some masks with 0xFFFFFFFF
disappear because uint32_t has only 32 bits.

Update flt_arith.3 to show that mantissa uses uint32_t.

Provide a target to install modules/src/flt_arith/test.c as flt_test
so I can run the tests.
2016-11-05 21:51:53 -04:00

30 lines
692 B
C

/*
(c) copyright 1989 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
#include <stdint.h>
#include "flt_misc.h"
int
flt_b64_add(e1,e2)
register struct flt_mantissa *e1,*e2;
{
int overflow;
int carry;
/* add higher pair of 32 bits */
overflow = (0xFFFFFFFFUL - e1->flt_h_32 < e2->flt_h_32);
e1->flt_h_32 += e2->flt_h_32;
/* add lower pair of 32 bits */
carry = (0xFFFFFFFFUL - e1->flt_l_32 < e2->flt_l_32);
e1->flt_l_32 += e2->flt_l_32;
if ((carry) && (++e1->flt_h_32 == 0))
return(1); /* had a 64 bit overflow */
return(overflow); /* return status from higher add */
}