3af72ceb18c658aef2b0ca82d8df916fe2e97035
[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.2 2003/06/17 04:26:53 dillon 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 __STDC__
31 #ifdef _SCALB_INT
32         float scalbf(float x, int fn)           /* wrapper scalbf */
33 #else
34         float scalbf(float x, float fn)         /* wrapper scalbf */
35 #endif
36 #else
37         float scalbf(x,fn)                      /* wrapper scalbf */
38 #ifdef _SCALB_INT
39         float x; int fn;
40 #else
41         float x,fn;
42 #endif
43 #endif
44 {
45 #ifdef _IEEE_LIBM
46         return __ieee754_scalbf(x,fn);
47 #else
48         float z;
49         z = __ieee754_scalbf(x,fn);
50         if(_LIB_VERSION == _IEEE_) return z;
51         if(!(finitef(z)||isnanf(z))&&finitef(x)) {
52             /* scalbf overflow */
53             return (float)__kernel_standard((double)x,(double)fn,132);
54         }
55         if(z==(float)0.0&&z!=x) {
56             /* scalbf underflow */
57             return (float)__kernel_standard((double)x,(double)fn,133);
58         }
59 #ifndef _SCALB_INT
60         if(!finitef(fn)) errno = ERANGE;
61 #endif
62         return z;
63 #endif
64 }