113618394Sjtc /* @(#)w_scalb.c 5.1 93/09/24 */
213618394Sjtc /*
313618394Sjtc * ====================================================
413618394Sjtc * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
513618394Sjtc *
613618394Sjtc * Developed at SunPro, a Sun Microsystems, Inc. business.
713618394Sjtc * Permission to use, copy, modify, and distribute this
813618394Sjtc * software is freely granted, provided that this notice
913618394Sjtc * is preserved.
1013618394Sjtc * ====================================================
1113618394Sjtc */
1213618394Sjtc
13118c71a6Slukem #include <sys/cdefs.h>
14d1f06e0bSjtc #if defined(LIBM_SCCS) && !defined(lint)
15*aa30599eSwiz __RCSID("$NetBSD: w_scalb.c,v 1.9 2002/05/26 22:02:02 wiz Exp $");
16af4a3642Sjtc #endif
17af4a3642Sjtc
1813618394Sjtc /*
1913618394Sjtc * wrapper scalb(double x, double fn) is provide for
2013618394Sjtc * passing various standard test suite. One
2113618394Sjtc * should use scalbn() instead.
2213618394Sjtc */
2313618394Sjtc
248346e333Sjtc #include "math.h"
258346e333Sjtc #include "math_private.h"
2613618394Sjtc
2713618394Sjtc #include <errno.h>
2813618394Sjtc
2913618394Sjtc #ifdef _SCALB_INT
30*aa30599eSwiz double
scalb(double x,int fn)31*aa30599eSwiz scalb(double x, int fn) /* wrapper scalb */
3213618394Sjtc #else
33*aa30599eSwiz double
34*aa30599eSwiz scalb(double x, double fn) /* wrapper scalb */
3513618394Sjtc #endif
3613618394Sjtc {
3713618394Sjtc #ifdef _IEEE_LIBM
3813618394Sjtc return __ieee754_scalb(x,fn);
3913618394Sjtc #else
4013618394Sjtc double z;
4113618394Sjtc z = __ieee754_scalb(x,fn);
4213618394Sjtc if(_LIB_VERSION == _IEEE_) return z;
4313618394Sjtc if(!(finite(z)||isnan(z))&&finite(x)) {
4413618394Sjtc return __kernel_standard(x,(double)fn,32); /* scalb overflow */
4513618394Sjtc }
4613618394Sjtc if(z==0.0&&z!=x) {
4713618394Sjtc return __kernel_standard(x,(double)fn,33); /* scalb underflow */
4813618394Sjtc }
4913618394Sjtc #ifndef _SCALB_INT
5013618394Sjtc if(!finite(fn)) errno = ERANGE;
5113618394Sjtc #endif
5213618394Sjtc return z;
5313618394Sjtc #endif
5413618394Sjtc }
55