]>
Commit | Line | Data |
---|---|---|
c624d232 TMQMF |
1 | /* Multiply by integral power of radix. |
2 | ||
2b778ceb | 3 | Copyright (C) 2011-2021 Free Software Foundation, Inc. |
c624d232 | 4 | |
0ac5ae23 | 5 | This file is part of the GNU C Library. |
f7eac6eb | 6 | |
0ac5ae23 UD |
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. | |
f7eac6eb | 11 | |
0ac5ae23 UD |
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 | |
59ba27a6 | 18 | License along with the GNU C Library; if not, see |
5a82c748 | 19 | <https://www.gnu.org/licenses/>. */ |
f7eac6eb | 20 | |
9d13fb24 | 21 | #include <math.h> |
9277c064 | 22 | #include <math_private.h> |
220622dd | 23 | #include <libm-alias-finite.h> |
0ac5ae23 | 24 | |
c624d232 | 25 | static FLOAT |
0ac5ae23 | 26 | __attribute__ ((noinline)) |
c624d232 | 27 | invalid_fn (FLOAT x, FLOAT fn) |
f7eac6eb | 28 | { |
c624d232 | 29 | if (M_SUF (rint) (fn) != fn) |
cb864fe0 | 30 | return (fn - fn) / (fn - fn); |
c624d232 TMQMF |
31 | else if (fn > M_LIT (65000.0)) |
32 | return M_SUF (__scalbn) (x, 65000); | |
0ac5ae23 | 33 | else |
c624d232 | 34 | return M_SUF (__scalbn) (x,-65000); |
0ac5ae23 UD |
35 | } |
36 | ||
37 | ||
c624d232 TMQMF |
38 | FLOAT |
39 | M_DECL_FUNC (__ieee754_scalb) (FLOAT x, FLOAT fn) | |
0ac5ae23 | 40 | { |
d81f90cc | 41 | if (__glibc_unlikely (isnan (x))) |
0ac5ae23 | 42 | return x * fn; |
d81f90cc | 43 | if (__glibc_unlikely (!isfinite (fn))) |
0ac5ae23 | 44 | { |
c624d232 | 45 | if (isnan (fn) || fn > M_LIT (0.0)) |
0ac5ae23 | 46 | return x * fn; |
c624d232 | 47 | if (x == M_LIT (0.0)) |
0ac5ae23 UD |
48 | return x; |
49 | return x / -fn; | |
50 | } | |
c624d232 TMQMF |
51 | if (__glibc_unlikely (M_FABS (fn) >= M_LIT (0x1p31) |
52 | || (FLOAT) (int) fn != fn)) | |
0ac5ae23 UD |
53 | return invalid_fn (x, fn); |
54 | ||
c624d232 | 55 | return M_SCALBN (x, (int) fn); |
f7eac6eb | 56 | } |
c624d232 | 57 | declare_mgen_finite_alias (__ieee754_scalb, __scalb) |