DBL->_s.p2 |= (f->m1 << DBL_LUNPACK); /* plus 10 == 32 */
/* if not exact then round to nearest */
+ /* on a tie, round to even */
#ifdef EXCEPTION_INEXACT
if ((f->m2 & DBL_EXACT) != 0) {
INEXACT();
#endif
- if (f->m2 & DBL_ROUNDUP) {
+ if (((f->m2 & DBL_EXACT) > DBL_ROUNDUP)
+ || ((f->m2 & DBL_EXACT) == DBL_ROUNDUP
+ && (f->m2 & (DBL_ROUNDUP << 1)))) {
DBL->_s.p2++; /* rounding up */
if (DBL->_s.p2 == 0L) { /* carry out */
DBL->_s.p1.fract++;
SGL->fract = (f->m1 >> SGL_RUNPACK);
/* check for rounding to nearest */
+ /* on a tie, round to even */
#ifdef EXCEPTION_INEXACT
if (f->m2 != 0 ||
(f->m1 & SGL_EXACT) != 0L) {
INEXACT();
#endif
- if (f->m1 & SGL_ROUNDUP) {
+ if (((f->m1 & SGL_EXACT) > SGL_ROUNDUP)
+ || ((f->m1 & SGL_EXACT) == SGL_ROUNDUP
+ && (f->m1 & (SGL_ROUNDUP << 1)))) {
SGL->fract++;
if (f->exp == 0 && (f->m1 & ~SGL_MASK)) {
f->exp++;
int leadbit = 0;
cpt1 = (char *) from;
- if (((DOUBLE *) cpt1)->_s.p1.fract == 0L ||
- ((DOUBLE *) cpt1)->_s.p1.fract == 0x80000000) {
- if (size == sizeof(SINGLE)) {
-zero: zrf_ext(to);
- return;
- }
- else if (((DOUBLE *) cpt1)->_s.p2 == 0L)
- goto zero;
- }
-/* there is a number to convert so lets get started */
#if FL_MSL_AT_LOW_ADDRESS
#if FL_MSW_AT_LOW_ADDRESS
cpt1 += 4;
to->m1 = get4(cpt1);
#endif
+ if (to->exp == 1 && to->m1 == 0 && tmp == 0) {
+ to->exp = 0;
+ to->sign = 0;
+ to->m1 = 0;
+ to->m2 = 0;
+ return;
+ }
to->m1 <<= DBL_M1LEFT; /* shift */
to->exp -= DBL_BIAS; /* remove bias */
to->m1 |= (tmp>>DBL_RPACK); /* plus 10 == 32 */
else { /* size == sizeof(SINGLE) */
to->m1 = get4(cpt1);
to->m1 <<= SGL_M1LEFT; /* shift */
+ if (to->exp == 1 && to->m1 == 0) {
+ to->exp = 0;
+ to->sign = 0;
+ to->m1 = 0;
+ to->m2 = 0;
+ return;
+ }
to->exp -= SGL_BIAS; /* remove bias */
to->m2 = 0L;
}