* posix/wordexp.c: Remove numerous NULL pointer tests before FREE
[glibc.git] / sysdeps / ieee754 / flt-32 / s_scalblnf.c
blob4ed48733cfbd019e4b747b2e31216e670a770f10
1 /* s_scalbnf.c -- float version of s_scalbn.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3 */
5 /*
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
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 * ====================================================
16 #if defined(LIBM_SCCS) && !defined(lint)
17 static char rcsid[] = "$NetBSD: s_scalbnf.c,v 1.4 1995/05/10 20:48:10 jtc Exp $";
18 #endif
20 #include "math.h"
21 #include "math_private.h"
23 #ifdef __STDC__
24 static const float
25 #else
26 static float
27 #endif
28 two25 = 3.355443200e+07, /* 0x4c000000 */
29 twom25 = 2.9802322388e-08, /* 0x33000000 */
30 huge = 1.0e+30,
31 tiny = 1.0e-30;
33 #ifdef __STDC__
34 float __scalblnf (float x, long int n)
35 #else
36 float __scalblnf (x,n)
37 float x; long int n;
38 #endif
40 int32_t k,ix;
41 GET_FLOAT_WORD(ix,x);
42 k = (ix&0x7f800000)>>23; /* extract exponent */
43 if (k==0) { /* 0 or subnormal x */
44 if ((ix&0x7fffffff)==0) return x; /* +-0 */
45 x *= two25;
46 GET_FLOAT_WORD(ix,x);
47 k = ((ix&0x7f800000)>>23) - 25;
49 if (k==0xff) return x+x; /* NaN or Inf */
50 k = k+n;
51 if (n> 50000 || k > 0xfe)
52 return huge*copysignf(huge,x); /* overflow */
53 if (n< -50000)
54 return tiny*copysignf(tiny,x); /*underflow*/
55 if (k > 0) /* normal result */
56 {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;}
57 if (k <= -25)
58 return tiny*copysignf(tiny,x); /*underflow*/
59 k += 25; /* subnormal result */
60 SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23));
61 return x*twom25;
63 weak_alias (__scalblnf, scalblnf)