2 (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 See the copyright notice in the ACK home directory, in the file "Copyright".
6 /* $Id: flt_add.c,v 1.7 1994/06/24 11:15:33 ceriel Exp $ */
12 register flt_arith *e1,*e2,*e3;
14 /* Add two extended numbers e1 and e2, and put the result
21 if ((e2->m1 | e2->m2) == 0L) {
25 if ((e1->m1 | e1->m2) == 0L) {
34 /* adjust mantissas to equal power */
35 diff = e2->flt_exp - e1->flt_exp;
39 flt_b64_sft(&(e2->flt_mantissa), diff);
43 flt_b64_sft(&(e1->flt_mantissa), diff);
45 if (e1->flt_sign != e2->flt_sign) {
46 /* e2 + e1 = e2 - (-e1) */
47 int tmp = ucmp(e1->m1, e2->m1);
48 int tmp2 = ucmp(e1->m2, e2->m2);
49 if (tmp > 0 || (tmp == 0 && tmp2 > 0)) {
50 /* abs(e1) > abs(e2) */
52 e1->m1 -= 1; /* carry in */
60 e2->m1 -= 1; /* carry in */
68 if (flt_b64_add(&e3->flt_mantissa,&e1->flt_mantissa)) {/* addition carry */
69 flt_b64_sft(&e3->flt_mantissa, 1);
70 e3->m1 |= 0x80000000L; /* set max bit */
71 e3->flt_exp++; /* increase the exponent */
80 flt_arith *e1,*e2,*e3;
82 e2->flt_sign = ! e2->flt_sign;
84 e2->flt_sign = ! e2->flt_sign;