qefgcvt.c 1.7 KB

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