1 /* ef_scalb.c -- float version of e_scalb.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3 */
4
5 /*
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 *
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
12 * is preserved.
13 * ====================================================
14 */
15
16 #include "fdlibm.h"
17 #include <limits.h>
18
19 float
scalbf(float x,float fn)20 scalbf(float x, float fn)
21 {
22 if (isnan(fn) || isnan(x))
23 return x + fn;
24
25 if (isinf(fn)) {
26 if ((x == 0.0f && fn > 0.0f) || (isinf(x) && fn < 0.0f))
27 return __math_invalidf(fn);
28 if (fn > 0.0f)
29 return fn*x;
30 else
31 return x/(-fn);
32 }
33
34 if (rintf(fn) != fn)
35 return __math_invalidf(fn);
36
37 if (fn > 4 * __FLT_MAX_EXP__)
38 fn = 4 * __FLT_MAX_EXP__;
39
40 if (fn < -4 * __FLT_MAX_EXP__)
41 fn = -4 * __FLT_MAX_EXP__;
42
43 return scalbnf(x, (int)fn);
44 }
45
46 _MATH_ALIAS_f_ff(scalb)
47