int ieee754sp_tint(ieee754sp x) { COMPXSP; CLEARCX; EXPLODEXSP; FLUSHXSP; switch (xc) { case IEEE754_CLASS_SNAN: case IEEE754_CLASS_QNAN: case IEEE754_CLASS_INF: SETCX(IEEE754_INVALID_OPERATION); return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x); case IEEE754_CLASS_ZERO: return 0; case IEEE754_CLASS_DNORM: case IEEE754_CLASS_NORM: break; } if (xe >= 31) { /* look for valid corner case */ if (xe == 31 && xs && xm == SP_HIDDEN_BIT) return -0x80000000; /* Set invalid. We will only use overflow for floating point overflow */ SETCX(IEEE754_INVALID_OPERATION); return ieee754si_xcpt(ieee754si_indef(), "sp_tint", x); } /* oh gawd */ if (xe > SP_MBITS) { xm <<= xe - SP_MBITS; } else { u32 residue; int round; int sticky; int odd; if (xe < -1) { residue = xm; round = 0; sticky = residue != 0; xm = 0; <<<<<<< HEAD } else {
int ieee754sp_cmp(ieee754sp x, ieee754sp y, int cmp, int sig) { COMPXSP; COMPYSP; EXPLODEXSP; EXPLODEYSP; FLUSHXSP; FLUSHYSP; CLEARCX; /* Even clear inexact flag here */ if (ieee754sp_isnan(x) || ieee754sp_isnan(y)) { if (sig || xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN) SETCX(IEEE754_INVALID_OPERATION); if (cmp & IEEE754_CUN) return 1; if (cmp & (IEEE754_CLT | IEEE754_CGT)) { if (sig && SETANDTESTCX(IEEE754_INVALID_OPERATION)) return ieee754si_xcpt(0, "fcmpf", x); } return 0; } else { int vx = x.bits; int vy = y.bits; if (vx < 0) vx = -vx ^ SP_SIGN_BIT; if (vy < 0) vy = -vy ^ SP_SIGN_BIT; if (vx < vy) return (cmp & IEEE754_CLT) != 0; else if (vx == vy) return (cmp & IEEE754_CEQ) != 0; else return (cmp & IEEE754_CGT) != 0; } }