qefgcvt_r.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Compatibility functions for floating point formatting, reentrant,
  2. long double versions.
  3. Copyright (C) 1996-2019 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <float.h>
  17. #define FLOAT_TYPE long double
  18. #define FUNC_PREFIX q
  19. #define FLOAT_FMT_FLAG "L"
  20. #define FLOAT_NAME_EXT l
  21. #define FLOAT_MIN_10_EXP LDBL_MIN_10_EXP
  22. #if LDBL_MANT_DIG == 64
  23. # define NDIGIT_MAX 21
  24. #elif LDBL_MANT_DIG == 53
  25. # define NDIGIT_MAX 17
  26. #elif LDBL_MANT_DIG == 113
  27. # define NDIGIT_MAX 36
  28. #elif LDBL_MANT_DIG == 106
  29. # define NDIGIT_MAX 34
  30. #elif LDBL_MANT_DIG == 56
  31. # define NDIGIT_MAX 18
  32. #else
  33. /* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a
  34. compile time constant here, so we cannot use it. */
  35. # error "NDIGIT_MAX must be precomputed"
  36. # define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0)))
  37. #endif
  38. #if LDBL_MIN_10_EXP == -37
  39. # define FLOAT_MIN_10_NORM 1.0e-37L
  40. #elif LDBL_MIN_10_EXP == -291
  41. # define FLOAT_MIN_10_NORM 1.0e-291L
  42. #elif LDBL_MIN_10_EXP == -307
  43. # define FLOAT_MIN_10_NORM 1.0e-307L
  44. #elif LDBL_MIN_10_EXP == -4931
  45. # define FLOAT_MIN_10_NORM 1.0e-4931L
  46. #else
  47. /* libc can't depend on libm. */
  48. # error "FLOAT_MIN_10_NORM must be precomputed"
  49. # define FLOAT_MIN_10_NORM exp10l (LDBL_MIN_10_EXP)
  50. #endif
  51. #include "efgcvt_r.c"