/* 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"2728ieee754dp ieee754dp_fsp(ieee754sp x)29{30COMPXSP;3132EXPLODEXSP;3334CLEARCX;3536FLUSHXSP;3738switch (xc) {39case IEEE754_CLASS_SNAN:40SETCX(IEEE754_INVALID_OPERATION);41return ieee754dp_nanxcpt(ieee754dp_indef(), "fsp");42case IEEE754_CLASS_QNAN:43return ieee754dp_nanxcpt(builddp(xs,44DP_EMAX + 1 + DP_EBIAS,45((u64) xm46<< (DP_MBITS -47SP_MBITS))), "fsp",48x);49case IEEE754_CLASS_INF:50return ieee754dp_inf(xs);51case IEEE754_CLASS_ZERO:52return ieee754dp_zero(xs);53case IEEE754_CLASS_DNORM:54/* normalize */55while ((xm >> SP_MBITS) == 0) {56xm <<= 1;57xe--;58}59break;60case IEEE754_CLASS_NORM:61break;62}6364/* CAN'T possibly overflow,underflow, or need rounding65*/6667/* drop the hidden bit */68xm &= ~SP_HIDDEN_BIT;6970return builddp(xs, xe + DP_EBIAS,71(u64) xm << (DP_MBITS - SP_MBITS));72}737475