localedata: dz_BT, bo_CN: convert to UTF-8
[glibc.git] / math / e_scalb_template.c
blobebcac599907cafda6f7737e7b9fbc29603a09782
1 /* Multiply by integral power of radix.
3 Copyright (C) 2011-2024 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
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.
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.
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 <https://www.gnu.org/licenses/>. */
21 #include <math.h>
22 #include <math_private.h>
23 #include <libm-alias-finite.h>
25 static FLOAT
26 __attribute__ ((noinline))
27 invalid_fn (FLOAT x, FLOAT fn)
29 if (M_SUF (rint) (fn) != fn)
30 return (fn - fn) / (fn - fn);
31 else if (fn > M_LIT (65000.0))
32 return M_SUF (__scalbn) (x, 65000);
33 else
34 return M_SUF (__scalbn) (x,-65000);
38 FLOAT
39 M_DECL_FUNC (__ieee754_scalb) (FLOAT x, FLOAT fn)
41 if (__glibc_unlikely (isnan (x)))
42 return x * fn;
43 if (__glibc_unlikely (!isfinite (fn)))
45 if (isnan (fn) || fn > M_LIT (0.0))
46 return x * fn;
47 if (x == M_LIT (0.0))
48 return x;
49 return x / -fn;
51 if (__glibc_unlikely (M_FABS (fn) >= M_LIT (0x1p31)
52 || (FLOAT) (int) fn != fn))
53 return invalid_fn (x, fn);
55 return M_SCALBN (x, (int) fn);
57 declare_mgen_finite_alias (__ieee754_scalb, __scalb)