Back to index

glibc  2.9
w_scalb.c
Go to the documentation of this file.
00001 /* @(#)w_scalb.c 5.1 93/09/24 */
00002 /*
00003  * ====================================================
00004  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00005  *
00006  * Developed at SunPro, a Sun Microsystems, Inc. business.
00007  * Permission to use, copy, modify, and distribute this
00008  * software is freely granted, provided that this notice
00009  * is preserved.
00010  * ====================================================
00011  */
00012 
00013 #if defined(LIBM_SCCS) && !defined(lint)
00014 static char rcsid[] = "$NetBSD: w_scalb.c,v 1.6 1995/05/10 20:49:48 jtc Exp $";
00015 #endif
00016 
00017 /*
00018  * wrapper scalb(double x, double fn) is provide for
00019  * passing various standard test suite. One
00020  * should use scalbn() instead.
00021  */
00022 
00023 #include <math.h>
00024 #include "math_private.h"
00025 
00026 #include <errno.h>
00027 
00028 #ifdef __STDC__
00029 #ifdef _SCALB_INT
00030        double __scalb(double x, int fn)          /* wrapper scalb */
00031 #else
00032        double __scalb(double x, double fn)       /* wrapper scalb */
00033 #endif
00034 #else
00035        double __scalb(x,fn)               /* wrapper scalb */
00036 #ifdef _SCALB_INT
00037        double x; int fn;
00038 #else
00039        double x,fn;
00040 #endif
00041 #endif
00042 {
00043 #ifdef _IEEE_LIBM
00044        return __ieee754_scalb(x,fn);
00045 #else
00046        double z;
00047        z = __ieee754_scalb(x,fn);
00048        if(_LIB_VERSION != _SVID_) return z;
00049        if(!(__finite(z)||__isnan(z))&&__finite(x)) {
00050            return __kernel_standard(x,(double)fn,32); /* scalb overflow */
00051        }
00052        if(z==0.0&&z!=x) {
00053            return __kernel_standard(x,(double)fn,33); /* scalb underflow */
00054        }
00055 #ifndef _SCALB_INT
00056        if(!__finite(fn)) __set_errno (ERANGE);
00057 #endif
00058        return z;
00059 #endif
00060 }
00061 weak_alias (__scalb, scalb)
00062 #ifdef NO_LONG_DOUBLE
00063 strong_alias (__scalb, __scalbl)
00064 weak_alias (__scalb, scalbl)
00065 #endif