]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/sparc/sparc64/soft-fp/s_scalbnl.c
ba62ec7e0c25fbfd1473cfb0d543998ca331915b
[thirdparty/glibc.git] / sysdeps / sparc / sparc64 / soft-fp / s_scalbnl.c
1 /* Software floating-point emulation.
2 scalbnl(x, exp)
3 Copyright (C) 1999-2016 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Jakub Jelinek (jj@ultra.linux.cz).
6
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
20
21 /*
22 * scalbnl (long double x, int n)
23 * scalbnl(x,n) returns x* 2**n computed by exponent
24 * manipulation rather than by actually performing an
25 * exponentiation or a multiplication.
26 */
27
28 #include "soft-fp.h"
29 #include "quad.h"
30
31 long double __scalbnl(long double arg, int exp)
32 {
33 FP_DECL_EX;
34 FP_DECL_Q(A);
35 long double r;
36
37 FP_UNPACK_Q(A, arg);
38 switch (A_c)
39 {
40 case FP_CLS_ZERO:
41 return arg;
42 case FP_CLS_NAN:
43 case FP_CLS_INF:
44 FP_HANDLE_EXCEPTIONS;
45 return arg;
46 }
47 A_e += exp;
48 FP_PACK_Q(r, A);
49 FP_HANDLE_EXCEPTIONS;
50
51 return r;
52 }