1 /* s_scalbnf.c -- float version of s_scalbn.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
4 * $FreeBSD: src/lib/msun/src/s_scalbnf.c,v 1.5 1999/08/28 00:06:54 peter Exp $
5 * $DragonFly: src/lib/msun/src/Attic/s_scalbnf.c,v 1.2 2003/06/17 04:26:53 dillon Exp $
9 * ====================================================
10 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
12 * Developed at SunPro, a Sun Microsystems, Inc. business.
13 * Permission to use, copy, modify, and distribute this
14 * software is freely granted, provided that this notice
16 * ====================================================
20 #include "math_private.h"
27 two25 = 3.355443200e+07, /* 0x4c000000 */
28 twom25 = 2.9802322388e-08, /* 0x33000000 */
33 float scalbnf (float x, int n)
41 k = (ix&0x7f800000)>>23; /* extract exponent */
42 if (k==0) { /* 0 or subnormal x */
43 if ((ix&0x7fffffff)==0) return x; /* +-0 */
46 k = ((ix&0x7f800000)>>23) - 25;
47 if (n< -50000) return tiny*x; /*underflow*/
49 if (k==0xff) return x+x; /* NaN or Inf */
51 if (k > 0xfe) return huge*copysignf(huge,x); /* overflow */
52 if (k > 0) /* normal result */
53 {SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23)); return x;}
55 if (n > 50000) /* in case integer overflow in n+k */
56 return huge*copysignf(huge,x); /*overflow*/
57 else return tiny*copysignf(tiny,x); /*underflow*/
58 k += 25; /* subnormal result */
59 SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23));