did not handle -0.0 right

This commit is contained in:
ceriel 1989-08-15 09:04:49 +00:00
parent 650c178631
commit 04dcaf5685
5 changed files with 25 additions and 7 deletions

View file

@ -30,8 +30,11 @@ _float f1,f2;
sign1 = SIGN(l1);
sign2 = SIGN(l2);
if (sign1 != sign2)
if (sign1 != sign2) {
if ((l1 & 0x7fffffff) == 0 &&
(l2 & 0x7fffffff) == 0) return 0;
return ((sign1 > 0) ? -1 : 1);
}
return (sign1 * ((l1 < l2) ? 1 : -1));
}

View file

@ -28,7 +28,11 @@ _double d1,d2;
sign1 = SIGN(l1);
sign2 = SIGN(l2);
if (sign1 != sign2) {
return ((sign1 > 0) ? -1 : 1);
l1 &= 0x7fffffff;
l2 &= 0x7fffffff;
if (l1 != 0 || l2 != 0) {
return ((sign1 > 0) ? -1 : 1);
}
}
if (l1 != l2) { /* we can decide here */
rv = l1 < l2 ? 1 : -1;

View file

@ -42,7 +42,8 @@ int size;
int leadbit = 0;
cpt1 = (char *) from;
if (((DOUBLE *) cpt1)->_s.p1.fract == 0L) {
if (((DOUBLE *) cpt1)->_s.p1.fract == 0L ||
((DOUBLE *) cpt1)->_s.p1.fract == 0x80000000) {
if (size == sizeof(SINGLE)) {
zero: zrf_ext(to);
return;

View file

@ -26,7 +26,12 @@ struct fef4_returns *r;
*/
extend((_double *) &s1,&buf,sizeof(_float));
p->e = buf.exp+1;
buf.exp = -1;
if (buf.exp == 0 && buf.m1 == 0 && buf.m2 == 0) {
p->e = 0;
}
else {
p->e = buf.exp+1;
buf.exp = -1;
}
compact(&buf,(_double *) &p->f,sizeof(_float));
}

View file

@ -26,7 +26,12 @@ struct fef8_returns *r;
*/
extend(&s1,&buf,sizeof(_double));
p->e = buf.exp + 1;
buf.exp = -1;
if (buf.exp == 0 && buf.m1 == 0 && buf.m2 == 0) {
p->e = 0;
}
else {
p->e = buf.exp + 1;
buf.exp = -1;
}
compact(&buf,&p->f,sizeof(_double));
}