ack/modules/src/flt_arith/b64_add.c

31 lines
750 B
C
Raw Normal View History

1989-07-10 11:17:19 +00:00
/*
(c) copyright 1989 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
# include "misc.h"
int
flt_b64_add(e1,e2)
register struct flt_mantissa *e1,*e2;
1989-07-10 11:17:19 +00:00
{
int overflow;
int carry;
/* add higher pair of 32 bits */
1989-11-08 12:52:41 +00:00
overflow = ucmp((long)0xFFFFFFFF - e1->flt_h_32, e2->flt_h_32) < 0;
1989-07-10 11:17:19 +00:00
e1->flt_h_32 += e2->flt_h_32;
/* add lower pair of 32 bits */
1989-11-08 12:52:41 +00:00
carry = ucmp((long)0xFFFFFFFF - e1->flt_l_32, e2->flt_l_32) < 0;
1989-07-10 11:17:19 +00:00
e1->flt_l_32 += e2->flt_l_32;
if ((carry) && ((++e1->flt_h_32 &~0xFFFFFFFF) || e1->flt_h_32 == 0)) {
e1->flt_h_32 = 0;
return(1); /* had a 64 bit overflow */
}
return(overflow); /* return status from higher add */
}