#include <sys/cdefs.h>
#if defined(LIBM_SCCS) && !defined(lint)
__RCSID("$NetBSD: w_scalb.c,v 1.9 2002/05/26 22:02:02 wiz Exp $");
#endif
#include "math.h"
#include "math_private.h"
#include <errno.h>
#ifdef _SCALB_INT
double
scalb(double x, int fn)
#else
double
scalb(double x, double fn)
#endif
{
#ifdef _IEEE_LIBM
return __ieee754_scalb(x,fn);
#else
double z;
z = __ieee754_scalb(x,fn);
if(_LIB_VERSION == _IEEE_) return z;
if(!(finite(z)||isnan(z))&&finite(x)) {
return __kernel_standard(x,(double)fn,32);
}
if(z==0.0&&z!=x) {
return __kernel_standard(x,(double)fn,33);
}
#ifndef _SCALB_INT
if(!finite(fn)) errno = ERANGE;
#endif
return z;
#endif
}