1 2 /* @(#)e_scalb.c 5.1 93/09/24 */ 3 /* 4 * ==================================================== 5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 6 * 7 * Developed at SunPro, a Sun Microsystems, Inc. business. 8 * Permission to use, copy, modify, and distribute this 9 * software is freely granted, provided that this notice 10 * is preserved. 11 * ==================================================== 12 */ 13 14 /* 15 * __ieee754_scalb(x, fn) is provide for 16 * passing various standard test suite. One 17 * should use scalbn() instead. 18 */ 19 20 #include "fdlibm.h" 21 22 #ifndef _DOUBLE_IS_32BITS 23 24 #ifdef _SCALB_INT 25 #ifdef __STDC__ __ieee754_scalb(double x,int fn)26 double __ieee754_scalb(double x, int fn) 27 #else 28 double __ieee754_scalb(x,fn) 29 double x; int fn; 30 #endif 31 #else 32 #ifdef __STDC__ 33 double __ieee754_scalb(double x, double fn) 34 #else 35 double __ieee754_scalb(x,fn) 36 double x, fn; 37 #endif 38 #endif 39 { 40 #ifdef _SCALB_INT 41 return scalbn(x,fn); 42 #else 43 if (isnan(x)||isnan(fn)) return x*fn; 44 if (!finite(fn)) { 45 if(fn>0.0) return x*fn; 46 else return x/(-fn); 47 } 48 if (rint(fn)!=fn) return (fn-fn)/(fn-fn); 49 if ( fn > 65000.0) return scalbn(x, 65000); 50 if (-fn > 65000.0) return scalbn(x,-65000); 51 return scalbn(x,(int)fn); 52 #endif 53 } 54 55 #endif /* defined(_DOUBLE_IS_32BITS) */ 56