Merge from vendor branch HEIMDAL:
[dragonfly.git] / lib / msun / src / w_scalbf.c
1 /* w_scalbf.c -- float version of w_scalb.c.
2  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3  *
4  * $FreeBSD: src/lib/msun/src/w_scalbf.c,v 1.5 1999/08/28 00:07:08 peter Exp $
5  * $DragonFly: src/lib/msun/src/Attic/w_scalbf.c,v 1.3 2004/12/29 15:22:57 asmodai Exp $
6  */
7
8 /*
9  * ====================================================
10  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
11  *
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
15  * is preserved.
16  * ====================================================
17  */
18
19 /*
20  * wrapper scalbf(float x, float fn) is provide for
21  * passing various standard test suite. One
22  * should use scalbn() instead.
23  */
24
25 #include "math.h"
26 #include "math_private.h"
27
28 #include <errno.h>
29
30 #ifdef _SCALB_INT
31         float scalbf(float x, int fn)           /* wrapper scalbf */
32 #else
33         float scalbf(float x, float fn)         /* wrapper scalbf */
34 #endif
35 {
36 #ifdef _IEEE_LIBM
37         return __ieee754_scalbf(x,fn);
38 #else
39         float z;
40         z = __ieee754_scalbf(x,fn);
41         if(_LIB_VERSION == _IEEE_) return z;
42         if(!(finitef(z)||isnanf(z))&&finitef(x)) {
43             /* scalbf overflow */
44             return (float)__kernel_standard((double)x,(double)fn,132);
45         }
46         if(z==(float)0.0&&z!=x) {
47             /* scalbf underflow */
48             return (float)__kernel_standard((double)x,(double)fn,133);
49         }
50 #ifndef _SCALB_INT
51         if(!finitef(fn)) errno = ERANGE;
52 #endif
53         return z;
54 #endif
55 }