Uninitialized vector entry?
[minix3.git] / lib / float / sub_ext.c
blob64180aa6f938399045f35f1cb3efcbaf57ad3ee6
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 SUBTRACT 2 EXTENDED FORMAT NUMBERS
12 #include "FP_types.h"
14 void
15 sub_ext(e1,e2)
16 EXTEND *e1,*e2;
18 if ((e2->m1 | e2->m2) == 0L) {
19 return;
21 if ((e1->m1 | e1->m2) == 0L) {
22 *e1 = *e2;
23 e1->sign = e2->sign ? 0 : 1;
24 return;
26 sft_ext(e1, e2);
27 if (e1->sign != e2->sign) {
28 /* e1 - e2 = e1 + (-e2) */
29 if (b64_add(&e1->mantissa,&e2->mantissa)) { /* addition carry */
30 b64_rsft(&e1->mantissa); /* shift mantissa one bit RIGHT */
31 e1->m1 |= 0x80000000L; /* set max bit */
32 e1->exp++; /* increase the exponent */
35 else if (e2->m1 > e1->m1 ||
36 (e2->m1 == e1->m1 && e2->m2 > e1->m2)) {
37 /* abs(e2) > abs(e1) */
38 if (e1->m2 > e2->m2) {
39 e2->m1 -= 1; /* carry in */
41 e2->m1 -= e1->m1;
42 e2->m2 -= e1->m2;
43 *e1 = *e2;
44 e1->sign = e2->sign ? 0 : 1;
46 else {
47 if (e2->m2 > e1->m2)
48 e1->m1 -= 1; /* carry in */
49 e1->m1 -= e2->m1;
50 e1->m2 -= e2->m2;
52 nrm_ext(e1);