s_scalbnl.c 1.4 KB

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