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/>. */
22 #include <math_private.h>
23 #include <libm-alias-finite.h>
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);
34 return M_SUF (__scalbn
) (x
,-65000);
39 M_DECL_FUNC (__ieee754_scalb
) (FLOAT x
, FLOAT fn
)
41 if (__glibc_unlikely (isnan (x
)))
43 if (__glibc_unlikely (!isfinite (fn
)))
45 if (isnan (fn
) || fn
> M_LIT (0.0))
51 if (__glibc_unlikely (M_FABS (fn
) >= M_LIT (0x1p
31)
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
)