]>
Commit | Line | Data |
---|---|---|
7ce331c0 EA |
1 | /* |
2 | * ==================================================== | |
3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | |
4 | * | |
5 | * Developed at SunPro, a Sun Microsystems, Inc. business. | |
6 | * Permission to use, copy, modify, and distribute this | |
c4e44e97 | 7 | * software is freely granted, provided that this notice |
7ce331c0 EA |
8 | * is preserved. |
9 | * ==================================================== | |
10 | */ | |
11 | ||
7ce331c0 EA |
12 | /* |
13 | * __ieee754_scalb(x, fn) is provide for | |
c4e44e97 | 14 | * passing various standard test suite. One |
7ce331c0 EA |
15 | * should use scalbn() instead. |
16 | */ | |
17 | ||
18 | #include "math.h" | |
19 | #include "math_private.h" | |
30bd4a6c | 20 | #include <errno.h> |
7ce331c0 | 21 | |
38b7304e | 22 | double attribute_hidden __ieee754_scalb(double x, double fn) |
7ce331c0 | 23 | { |
7ce331c0 | 24 | return scalbn(x,fn); |
7ce331c0 | 25 | if (isnan(x)||isnan(fn)) return x*fn; |
a0ebeb98 | 26 | if (!isfinite(fn)) { |
7ce331c0 EA |
27 | if(fn>0.0) return x*fn; |
28 | else return x/(-fn); | |
29 | } | |
30 | if (rint(fn)!=fn) return (fn-fn)/(fn-fn); | |
31 | if ( fn > 65000.0) return scalbn(x, 65000); | |
32 | if (-fn > 65000.0) return scalbn(x,-65000); | |
33 | return scalbn(x,(int)fn); | |
7ce331c0 | 34 | } |
30bd4a6c | 35 | |
3a40407c | 36 | #if defined __UCLIBC_SUSV3_LEGACY__ |
30bd4a6c DV |
37 | /* |
38 | * wrapper scalb(double x, double fn) is provide for | |
39 | * passing various standard test suite. One | |
40 | * should use scalbn() instead. | |
41 | */ | |
42 | #ifndef _IEEE_LIBM | |
30bd4a6c | 43 | double scalb(double x, double fn) |
30bd4a6c DV |
44 | { |
45 | double z = __ieee754_scalb(x, fn); | |
46 | if (_LIB_VERSION == _IEEE_) | |
47 | return z; | |
48 | if (!(isfinite(z) || isnan(z)) && isfinite(x)) | |
49 | return __kernel_standard(x, (double)fn, 32); /* scalb overflow */ | |
50 | if (z == 0.0 && z != x) | |
51 | return __kernel_standard(x, (double)fn, 33); /* scalb underflow */ | |
30bd4a6c DV |
52 | if (!isfinite(fn)) |
53 | errno = ERANGE; | |
30bd4a6c DV |
54 | return z; |
55 | } | |
56 | #else | |
57 | strong_alias(__ieee754_scalb, scalb) | |
58 | #endif | |
3a40407c BRF |
59 | |
60 | #endif /* UCLIBC_SUSV3_LEGACY */ |