986
|
1 |
|
|
2 |
/* @(#)w_scalb.c 1.3 95/01/18 */
|
|
3 |
/*
|
|
4 |
* ====================================================
|
|
5 |
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
6 |
*
|
|
7 |
* Developed at SunSoft, 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 |
/*
|
|
15 |
* wrapper scalb(double x, double fn) is provide for
|
|
16 |
* passing various standard test suite. One
|
|
17 |
* should use scalbn() instead.
|
|
18 |
*/
|
|
19 |
|
|
20 |
#include "fdlibm.h"
|
|
21 |
|
|
22 |
#include <errno.h>
|
|
23 |
|
|
24 |
#ifdef __STDC__
|
|
25 |
#ifdef _SCALB_INT
|
|
26 |
double scalb(double x, int fn) /* wrapper scalb */
|
|
27 |
#else
|
|
28 |
double scalb(double x, double fn) /* wrapper scalb */
|
|
29 |
#endif
|
|
30 |
#else
|
|
31 |
double scalb(x,fn) /* wrapper scalb */
|
|
32 |
#ifdef _SCALB_INT
|
|
33 |
double x; int fn;
|
|
34 |
#else
|
|
35 |
double x,fn;
|
|
36 |
#endif
|
|
37 |
#endif
|
|
38 |
{
|
|
39 |
#ifdef _IEEE_LIBM
|
|
40 |
return __ieee754_scalb(x,fn);
|
|
41 |
#else
|
|
42 |
double z;
|
|
43 |
z = __ieee754_scalb(x,fn);
|
|
44 |
if(_LIB_VERSION == _IEEE_) return z;
|
|
45 |
if(!(finite(z)||isnan(z))&&finite(x)) {
|
|
46 |
return __kernel_standard(x,(double)fn,32); /* scalb overflow */
|
|
47 |
}
|
|
48 |
if(z==0.0&&z!=x) {
|
|
49 |
return __kernel_standard(x,(double)fn,33); /* scalb underflow */
|
|
50 |
}
|
|
51 |
#ifndef _SCALB_INT
|
|
52 |
if(!finite(fn)) errno = ERANGE;
|
|
53 |
#endif
|
|
54 |
return z;
|
|
55 |
#endif
|
|
56 |
}
|