adf and sbf did not work with 0.0

This commit is contained in:
ceriel 1988-07-22 20:54:49 +00:00
parent 44ce140103
commit 24c59f9f68
5 changed files with 31 additions and 7 deletions

View file

@ -18,6 +18,13 @@ _float s1,s2;
EXTEND e1,e2;
int swap = 0;
if (s1 == (_float) 0) {
s1 = s2;
return s1;
}
if (s2 == (_float) 0) {
return s1;
}
extend((_double *)&s1,&e1,sizeof(SINGLE));
extend((_double *)&s2,&e2,sizeof(SINGLE));
/* if signs differ do subtraction */

View file

@ -17,6 +17,15 @@ _double s1,s2;
{
EXTEND e1,e2;
short swap;
if (s1.__double[0] == 0 && s1.__double[1] == 0) {
s1 = s2;
return s1;
}
if (s2.__double[0] == 0 && s2.__double[1] == 0) {
return s1;
}
extend(&s1,&e1,sizeof(_double));
extend(&s2,&e2,sizeof(_double));
#ifdef PRT_EXT

View file

@ -22,25 +22,27 @@ _double d1,d2;
*/
long l1,l2;
int sign1,sign2;
int rv;
l1 = get4((char *)&d1);
l2 = get4((char *)&d2);
sign1 = SIGN(l1);
sign2 = SIGN(l2);
if (sign1 != sign2)
if (sign1 != sign2) {
return ((sign1 > 0) ? -1 : 1);
}
if (l1 != l2) { /* we can decide here */
return sign1 * (l1 < l2 ? 1 : -1) ;
rv = l1 < l2 ? 1 : -1;
}
else { /* decide in 2nd half */
l1 = get4(((char *)&d1 + 4));
l2 = get4(((char *)&d2 + 4));
if (l1 == l2)
return(0);
if (l1 < 0)
return l2 < 0 ? l2 > l1 : -1;
if (l2 < 0)
return 1;
return l2 > l1 ? 1 : -1;
if (l1 >= 0)
rv = l1 < l2 || l2 < 0 ? 1 : -1;
else if (l2 >= 0) rv = -1;
else rv = l1 < l2 ? 1 : -1;
}
return sign1 * rv;
}

View file

@ -22,6 +22,9 @@ _float s1,s2;
/* s2 = -s2 */
char unsigned *p;
if (s2 == (_float) 0) {
return s1;
}
p = (char unsigned *) &s2;
*p ^= 0x80; /* change sign of s2 */
s1 = adf4(s2,s1);

View file

@ -25,6 +25,9 @@ _double s1,s2;
#ifdef PRT_EXT
fprintf(stderr,"SBF8 ():\n");
#endif
if (s2.__double[0] == 0 && s2.__double[1] == 0) {
return s1;
}
p = (char unsigned *) &s2;
*p ^= 0x80; /* change sign of s2 */
s1 = adf8(s2,s1); /* add and return result */