Pristine Ack-5.5
[Ack-5.5.git] / modules / src / flt_arith / b64_add.c
1 /*
2   (c) copyright 1989 by the Vrije Universiteit, Amsterdam, The Netherlands.
3   See the copyright notice in the ACK home directory, in the file "Copyright".
4 */
5
6 /* $Id: b64_add.c,v 1.6 1994/06/24 11:15:27 ceriel Exp $ */
7
8 #include "flt_misc.h"
9
10 int
11 flt_b64_add(e1,e2)
12         register struct flt_mantissa *e1,*e2;
13 {
14         int     overflow;
15         int     carry;
16
17         /* add higher pair of 32 bits */
18         overflow = ucmp((long)0xFFFFFFFF - e1->flt_h_32, e2->flt_h_32) < 0;
19         e1->flt_h_32 += e2->flt_h_32;
20
21         /* add lower pair of 32 bits */
22         carry = ucmp((long)0xFFFFFFFF - e1->flt_l_32, e2->flt_l_32) < 0;
23         e1->flt_l_32 += e2->flt_l_32;
24
25         if ((carry) && ((++e1->flt_h_32 &~0xFFFFFFFF) || e1->flt_h_32 == 0)) {
26                 e1->flt_h_32 = 0;
27                 return(1);              /* had a 64 bit overflow */
28         }
29         return(overflow);       /* return status from higher add */
30 }