[BZ #6803] Set errno for scalbln, scalbn
[platform/upstream/glibc.git] / sysdeps / sparc / sparc64 / soft-fp / s_scalblnl.c
1 /* Software floating-point emulation.
2    scalblnl(x, exp)
3    Copyright (C) 1999-2014 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  * scalblnl (long double x, long int n)
23  * scalblnl(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 __scalblnl(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 }