1 /* @(#)w_scalb.c 5.1 93/09/24 */ 2 /* 3 * ==================================================== 4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 * 6 * Developed at SunPro, a Sun Microsystems, Inc. business. 7 * Permission to use, copy, modify, and distribute this 8 * software is freely granted, provided that this notice 9 * is preserved. 10 * ==================================================== 11 */ 12 13 #include <sys/cdefs.h> 14 #if defined(LIBM_SCCS) && !defined(lint) 15 __RCSID("$NetBSD: w_scalb.c,v 1.9 2002/05/26 22:02:02 wiz 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 "math_private.h" 26 27 #include <errno.h> 28 29 #ifdef _SCALB_INT 30 double 31 scalb(double x, int fn) /* wrapper scalb */ 32 #else 33 double 34 scalb(double x, double fn) /* wrapper scalb */ 35 #endif 36 { 37 #ifdef _IEEE_LIBM 38 return __ieee754_scalb(x,fn); 39 #else 40 double z; 41 z = __ieee754_scalb(x,fn); 42 if(_LIB_VERSION == _IEEE_) return z; 43 if(!(finite(z)||isnan(z))&&finite(x)) { 44 return __kernel_standard(x,(double)fn,32); /* scalb overflow */ 45 } 46 if(z==0.0&&z!=x) { 47 return __kernel_standard(x,(double)fn,33); /* scalb underflow */ 48 } 49 #ifndef _SCALB_INT 50 if(!finite(fn)) errno = ERANGE; 51 #endif 52 return z; 53 #endif 54 } 55