Uninitialized vector entry?
[minix3.git] / lib / float / add_ext.c
bloba077663ab3dc5cba5677a4843cb96d5939120c59
1 /*
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".
4 */
6 /* $Header$ */
8 /*
9 ADD TWO EXTENDED FORMAT NUMBERS
12 #include "FP_types.h"
14 void
15 add_ext(e1,e2)
16 register EXTEND *e1,*e2;
18 if ((e2->m1 | e2->m2) == 0L) {
19 return;
21 if ((e1->m1 | e1->m2) == 0L) {
22 *e1 = *e2;
23 return;
25 sft_ext(e1, e2); /* adjust mantissas to equal powers */
26 if (e1->sign != e2->sign) {
27 /* e1 + e2 = e1 - (-e2) */
28 if (e2->m1 > e1->m1 ||
29 (e2->m1 == e1->m1 && e2->m2 > e1->m2)) {
30 /* abs(e2) > abs(e1) */
31 EXTEND x;
33 x = *e1;
34 *e1 = *e2;
35 if (x.m2 > e1->m2) {
36 e1->m1 -= 1; /* carry in */
38 e1->m1 -= x.m1;
39 e1->m2 -= x.m2;
41 else {
42 if (e2->m2 > e1->m2)
43 e1->m1 -= 1; /* carry in */
44 e1->m1 -= e2->m1;
45 e1->m2 -= e2->m2;
48 else {
49 if (b64_add(&e1->mantissa,&e2->mantissa)) { /* addition carry */
50 b64_rsft(&e1->mantissa); /* shift mantissa one bit RIGHT */
51 e1->m1 |= 0x80000000L; /* set max bit */
52 e1->exp++; /* increase the exponent */
55 nrm_ext(e1);