/* IEEE754 floating point arithmetic1* single precision2*/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 "ieee754sp.h"2728int ieee754sp_finite(ieee754sp x)29{30return SPBEXP(x) != SP_EMAX + 1 + SP_EBIAS;31}3233ieee754sp ieee754sp_copysign(ieee754sp x, ieee754sp y)34{35CLEARCX;36SPSIGN(x) = SPSIGN(y);37return x;38}394041ieee754sp ieee754sp_neg(ieee754sp x)42{43COMPXSP;4445EXPLODEXSP;46CLEARCX;47FLUSHXSP;4849/*50* Invert the sign ALWAYS to prevent an endless recursion on51* pow() in libc.52*/53/* quick fix up */54SPSIGN(x) ^= 1;5556if (xc == IEEE754_CLASS_SNAN) {57ieee754sp y = ieee754sp_indef();58SETCX(IEEE754_INVALID_OPERATION);59SPSIGN(y) = SPSIGN(x);60return ieee754sp_nanxcpt(y, "neg");61}6263return x;64}656667ieee754sp ieee754sp_abs(ieee754sp x)68{69COMPXSP;7071EXPLODEXSP;72CLEARCX;73FLUSHXSP;7475/* Clear sign ALWAYS, irrespective of NaN */76SPSIGN(x) = 0;7778if (xc == IEEE754_CLASS_SNAN) {79SETCX(IEEE754_INVALID_OPERATION);80return ieee754sp_nanxcpt(ieee754sp_indef(), "abs");81}8283return x;84}858687