xref: /netbsd-src/lib/libm/src/w_scalbf.c (revision ce0bb6e8d2e560ecacbe865a848624f94498063b)
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 
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 #if defined(LIBM_SCCS) && !defined(lint)
17 static char rcsid[] = "$Id: w_scalbf.c,v 1.2 1994/09/22 16:46:04 jtc Exp $";
18 #endif
19 
20 /*
21  * wrapper scalbf(float x, float fn) is provide for
22  * passing various standard test suite. One
23  * should use scalbn() instead.
24  */
25 
26 #include "math.h"
27 #include "math_private.h"
28 
29 #include <errno.h>
30 
31 #ifdef __STDC__
32 #ifdef _SCALB_INT
33 	float scalbf(float x, int fn)		/* wrapper scalbf */
34 #else
35 	float scalbf(float x, float fn)		/* wrapper scalbf */
36 #endif
37 #else
38 	float scalbf(x,fn)			/* wrapper scalbf */
39 #ifdef _SCALB_INT
40 	float x; int fn;
41 #else
42 	float x,fn;
43 #endif
44 #endif
45 {
46 #ifdef _IEEE_LIBM
47 	return __ieee754_scalbf(x,fn);
48 #else
49 	float z;
50 	z = __ieee754_scalbf(x,fn);
51 	if(_LIB_VERSION == _IEEE_) return z;
52 	if(!(finitef(z)||isnanf(z))&&finitef(x)) {
53 	    /* scalbf overflow */
54 	    return (float)__kernel_standard((double)x,(double)fn,132);
55 	}
56 	if(z==(float)0.0&&z!=x) {
57 	    /* scalbf underflow */
58 	    return (float)__kernel_standard((double)x,(double)fn,133);
59 	}
60 #ifndef _SCALB_INT
61 	if(!finitef(fn)) errno = ERANGE;
62 #endif
63 	return z;
64 #endif
65 }
66