/* IEEE754 floating point arithmetic1* double precision: common utilities2*/3/*4* MIPS floating point support5* Copyright (C) 1994-2000 Algorithmics Ltd.6*7* ########################################################################8*9* This program is free software; you can distribute it and/or modify it10* under the terms of the GNU General Public License (Version 2) as11* published by the Free Software Foundation.12*13* This program is distributed in the hope it will be useful, but WITHOUT14* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or15* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License16* for more details.17*18* You should have received a copy of the GNU General Public License along19* with this program; if not, write to the Free Software Foundation, Inc.,20* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.21*22* ########################################################################23*/242526#include "ieee754dp.h"2728int ieee754dp_cmp(ieee754dp x, ieee754dp y, int cmp, int sig)29{30COMPXDP;31COMPYDP;3233EXPLODEXDP;34EXPLODEYDP;35FLUSHXDP;36FLUSHYDP;37CLEARCX; /* Even clear inexact flag here */3839if (ieee754dp_isnan(x) || ieee754dp_isnan(y)) {40if (sig || xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN)41SETCX(IEEE754_INVALID_OPERATION);42if (cmp & IEEE754_CUN)43return 1;44if (cmp & (IEEE754_CLT | IEEE754_CGT)) {45if (sig && SETANDTESTCX(IEEE754_INVALID_OPERATION))46return ieee754si_xcpt(0, "fcmpf", x);47}48return 0;49} else {50s64 vx = x.bits;51s64 vy = y.bits;5253if (vx < 0)54vx = -vx ^ DP_SIGN_BIT;55if (vy < 0)56vy = -vy ^ DP_SIGN_BIT;5758if (vx < vy)59return (cmp & IEEE754_CLT) != 0;60else if (vx == vy)61return (cmp & IEEE754_CEQ) != 0;62else63return (cmp & IEEE754_CGT) != 0;64}65}666768