w_scalb.c
1 #if !defined(__ppc__) 2 /* @(#)w_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 #if defined(LIBM_SCCS) && !defined(lint) 15 static char rcsid[] = "$NetBSD: w_scalb.c,v 1.6 1995/05/10 20:49:48 jtc Exp $"; 16 #endif 17 18 /* 19 * wrapper scalb(double x, double fn) is provide for 20 * passing various standard test suite. One 21 * should use scalbn() instead. 22 */ 23 24 #include "math.h" 25 #include "mathP.h" 26 27 #include <linux/errno.h> 28 29 extern int libm_errno; 30 31 #ifdef __STDC__ 32 #ifdef _SCALB_INT 33 double scalb(double x, int fn) /* wrapper scalb */ 34 #else 35 double scalb(double x, double fn) /* wrapper scalb */ 36 #endif 37 #else 38 double scalb(x,fn) /* wrapper scalb */ 39 #ifdef _SCALB_INT 40 double x; int fn; 41 #else 42 double x,fn; 43 #endif 44 #endif 45 { 46 #ifdef _IEEE_LIBM 47 return __ieee754_scalb(x,fn); 48 #else 49 double z; 50 z = __ieee754_scalb(x,fn); 51 if(_LIB_VERSION == _IEEE_) return z; 52 if(!(finite(z)||isnan(z))&&finite(x)) { 53 return __kernel_standard(x,(double)fn,32); /* scalb overflow */ 54 } 55 if(z==0.0&&z!=x) { 56 return __kernel_standard(x,(double)fn,33); /* scalb underflow */ 57 } 58 #ifndef _SCALB_INT 59 if(!finite(fn)) libm_errno = ERANGE; 60 #endif 61 return z; 62 #endif 63 } 64 #endif /* !__ppc__ */