s_frexpl.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Software floating-point emulation.
  2. frexpl(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. * for non-zero x
  19. * x = frexpl(arg,&exp);
  20. * return a long double fp quantity x such that 0.5 <= |x| <1.0
  21. * and the corresponding binary exponent "exp". That is
  22. * arg = x*2^exp.
  23. * If arg is inf, 0.0, or NaN, then frexpl(arg,&exp) returns arg
  24. * with *exp=0.
  25. */
  26. #include "soft-fp.h"
  27. #include "quad.h"
  28. long double __frexpl(long double arg, int *exp)
  29. {
  30. FP_DECL_EX;
  31. FP_DECL_Q(A);
  32. long double r;
  33. *exp = 0;
  34. FP_UNPACK_Q(A, arg);
  35. if (A_c != FP_CLS_NORMAL)
  36. return arg;
  37. *exp = A_e + 1;
  38. A_e = -1;
  39. FP_PACK_Q(r, A);
  40. return r;
  41. }
  42. weak_alias (__frexpl, frexpl)