Update.
[jlayton/glibc.git] / sysdeps / generic / e_scalbl.c
1 /* e_scalbl.c -- long double version of s_scalb.c.
2  * Conversion to long double by Ulrich Drepper,
3  * Cygnus Support, drepper@cygnus.com.
4  */
5
6 /*
7  * ====================================================
8  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9  *
10  * Developed at SunPro, a Sun Microsystems, Inc. business.
11  * Permission to use, copy, modify, and distribute this
12  * software is freely granted, provided that this notice
13  * is preserved.
14  * ====================================================
15  */
16
17 #if defined(LIBM_SCCS) && !defined(lint)
18 static char rcsid[] = "$NetBSD: $";
19 #endif
20
21 /*
22  * __ieee754_scalbl(x, fn) is provide for
23  * passing various standard test suite. One
24  * should use scalbnl() instead.
25  */
26
27 #include "math.h"
28 #include "math_private.h"
29
30 #ifdef _SCALB_INT
31 #ifdef __STDC__
32         long double __ieee754_scalbl(long double x, int fn)
33 #else
34         long double __ieee754_scalbl(x,fn)
35         long double x; int fn;
36 #endif
37 #else
38 #ifdef __STDC__
39         long double __ieee754_scalbl(long double x, long double fn)
40 #else
41         long double __ieee754_scalbl(x,fn)
42         long double x, fn;
43 #endif
44 #endif
45 {
46 #ifdef _SCALB_INT
47         return __scalbnl(x,fn);
48 #else
49         if (__isnanl(x)||__isnanl(fn)) return x*fn;
50         if (!__finitel(fn)) {
51             if(fn>0.0) return x*fn;
52             else if (x == 0)
53               return x;
54             else if (!__finitel (x))
55               return __nanl ("");
56             else       return x/(-fn);
57         }
58         if (__rintl(fn)!=fn) return __nanl ("");
59         if ( fn > 65000.0) return __scalbnl(x, 65000);
60         if (-fn > 65000.0) return __scalbnl(x,-65000);
61         return __scalbnl(x,(int)fn);
62 #endif
63 }