chiark / gitweb /
eglibc (2.11.3-4+deb6u3) squeeze-lts; urgency=medium
[eglibc.git] / math / 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 <fenv.h>
28 #include <math.h>
29 #include "math_private.h"
30
31 #ifdef _SCALB_INT
32 #ifdef __STDC__
33         long double __ieee754_scalbl(long double x, int fn)
34 #else
35         long double __ieee754_scalbl(x,fn)
36         long double x; int fn;
37 #endif
38 #else
39 #ifdef __STDC__
40         long double __ieee754_scalbl(long double x, long double fn)
41 #else
42         long double __ieee754_scalbl(x,fn)
43         long double x, fn;
44 #endif
45 #endif
46 {
47 #ifdef _SCALB_INT
48         return __scalbnl(x,fn);
49 #else
50         if (__isnanl(x)||__isnanl(fn)) return x*fn;
51         if (!__finitel(fn)) {
52             if(fn>0.0) return x*fn;
53             else if (x == 0)
54               return x;
55             else if (!__finitel (x))
56               {
57 # ifdef FE_INVALID
58                 feraiseexcept (FE_INVALID);
59 # endif
60                 return __nanl ("");
61               }
62             else       return x/(-fn);
63         }
64         if (__rintl(fn)!=fn)
65           {
66 # ifdef FE_INVALID
67             feraiseexcept (FE_INVALID);
68 # endif
69             return __nanl ("");
70           }
71         if ( fn > 65000.0) return __scalbnl(x, 65000);
72         if (-fn > 65000.0) return __scalbnl(x,-65000);
73         return __scalbnl(x,(int)fn);
74 #endif
75 }