/* Floating point output for `printf'. Copyright (C) 1995-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <config.h>#include <float.h>#include <limits.h>#include <math.h>#include <string.h>#include <unistd.h>#include <stdlib.h>#include <stdbool.h>#define NDEBUG#include <assert.h>#ifdef HAVE_ERRNO_H#include <errno.h>#endif#include <stdio.h>#include <stdarg.h>#ifdef HAVE_FENV_H#include "quadmath-rounding-mode.h"#endif#include "quadmath-printf.h"#include "fpioconst.h" #ifdef USE_I18N_NUMBER_H#include "_i18n_number.h"#endif /* Macros for doing the actual output. */ #define outchar(ch) \ do \ { \ register const int outc = (ch); \ if (PUTC (outc, fp) == EOF) \ { \ if (buffer_malloced) \ free (wbuffer); \ return -1; \ } \ ++done; \ } while (0) #define PRINT(ptr, wptr, len) \ do \ { \ register size_t outlen = (len); \ if (len > 20) \ { \ if (PUT (fp, wide ? (const char *) wptr : ptr, outlen) != outlen) \ { \ if (buffer_malloced) \ free (wbuffer); \ return -1; \ } \ ptr += outlen; \ done += outlen; \ } \ else \ { \ if (wide) \ while (outlen-- > 0) \ outchar (*wptr++); \ else \ while (outlen-- > 0) \ outchar (*ptr++); \ } \ } while (0) #define PADN(ch, len) \ do \ { \ if (PAD (fp, ch, len) != len) \ { \ if (buffer_malloced) \ free (wbuffer); \ return -1; \ } \ done += len; \ } \ while (0) /* We use the GNU MP library to handle large numbers. An MP variable occupies a varying number of entries in its array. We keep track of this number for efficiency reasons. Otherwise we would always have to process the whole array. */#define MPN_VAR(name) mp_limb_t *name; mp_size_t name##size #define MPN_ASSIGN(dst,src) \ memcpy (dst, src, (dst##size = src##size) * sizeof (mp_limb_t))#define MPN_GE(u,v) \ (u##size > v##size || (u##size == v##size && mpn_cmp (u, v, u##size) >= 0)) extern mp_size_t mpn_extract_flt128 (mp_ptr res_ptr, mp_size_t size, int *expt, int *is_neg, __float128 value) attribute_hidden;static unsigned int guess_grouping (unsigned int intdig_max, const char *grouping); static wchar_t *group_number (wchar_t *buf, wchar_t *bufend, unsigned int intdig_no, const char *grouping, wchar_t thousands_sep, int ngroups); int__quadmath_printf_fp (struct __quadmath_printf_file *fp, const struct printf_info *info, const void *const *args){ /* The floating-point value to output. */ __float128 fpnum; /* Locale-dependent representation of decimal point. */ const char *decimal; wchar_t decimalwc; /* Locale-dependent thousands separator and grouping specification. */ const char *thousands_sep = NULL; wchar_t thousands_sepwc = L_('\0'); const char *grouping; /* "NaN" or "Inf" for the special cases. */ const char *special = NULL; const wchar_t *wspecial = NULL; /* We need just a few limbs for the input before shifting to the right position. */ mp_limb_t fp_input[(FLT128_MANT_DIG + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB]; /* We need to shift the contents of fp_input by this amount of bits. */ int to_shift = 0; /* The fraction of the floting-point value in question */ MPN_VAR(frac); /* and the exponent. */ int exponent; /* Sign of the exponent. */ int expsign = 0; /* Sign of float number. */ int is_neg = 0; /* Scaling factor. */ MPN_VAR(scale); /* Temporary bignum value. */ MPN_VAR(tmp); /* Digit which is result of last hack_digit() call. */ wchar_t last_digit, next_digit; bool more_bits; /* The type of output format that will be used: 'e'/'E' or 'f'. */ int type; /* Counter for number of written characters. */ int done = 0; /* General helper (carry limb). */ mp_limb_t cy; /* Nonzero if this is output on a wide character stream. */ int wide = info->wide; /* Buffer in which we produce the output. */ wchar_t *wbuffer = NULL; /* Flag whether wbuffer is malloc'ed or not. */ int buffer_malloced = 0; auto wchar_t hack_digit (void); wchar_t hack_digit (void) { mp_limb_t hi; if (expsign != 0 && type == 'f' && exponent-- > 0) hi = 0; else if (scalesize == 0) { hi = frac[fracsize - 1]; frac[fracsize - 1] = mpn_mul_1 (frac, frac, fracsize - 1, 10); } else { if (fracsize < scalesize) hi = 0; else { hi = mpn_divmod (tmp, frac, fracsize, scale, scalesize); tmp[fracsize - scalesize] = hi; hi = tmp[0]; fracsize = scalesize; while (fracsize != 0 && frac[fracsize - 1] == 0) --fracsize; if (fracsize == 0) { /* We're not prepared for an mpn variable with zero limbs. */ fracsize = 1; return L_('0') + hi; } } mp_limb_t _cy = mpn_mul_1 (frac, frac, fracsize, 10); if (_cy != 0) frac[fracsize++] = _cy; } return L_('0') + hi; } /* Figure out the decimal point character. */#ifdef USE_NL_LANGINFO if (info->extra == 0) decimal = nl_langinfo (DECIMAL_POINT); else { decimal = nl_langinfo (MON_DECIMAL_POINT); if (*decimal == '\0') decimal = nl_langinfo (DECIMAL_POINT); } /* The decimal point character must never be zero. */ assert (*decimal != '\0');#elif defined USE_LOCALECONV const struct lconv *lc = localeconv (); if (info->extra == 0) decimal = lc->decimal_point; else { decimal = lc->mon_decimal_point; if (decimal == NULL || *decimal == '\0') decimal = lc->decimal_point; } if (decimal == NULL || *decimal == '\0') decimal = ".";#else decimal = ".";#endif#ifdef USE_NL_LANGINFO_WC if (info->extra == 0) decimalwc = nl_langinfo_wc (_NL_NUMERIC_DECIMAL_POINT_WC); else { decimalwc = nl_langinfo_wc (_NL_MONETARY_DECIMAL_POINT_WC); if (decimalwc == L_('\0')) decimalwc = nl_langinfo_wc (_NL_NUMERIC_DECIMAL_POINT_WC); } /* The decimal point character must never be zero. */ assert (decimalwc != L_('\0'));#else decimalwc = L_('.');#endif #if defined USE_NL_LANGINFO && defined USE_NL_LANGINFO_WC if (info->group) { if (info->extra == 0) grouping = nl_langinfo (GROUPING); else grouping = nl_langinfo (MON_GROUPING); if (*grouping <= 0 || *grouping == CHAR_MAX) grouping = NULL; else { /* Figure out the thousands separator character. */ if (wide) { if (info->extra == 0) thousands_sepwc = nl_langinfo_wc (_NL_NUMERIC_THOUSANDS_SEP_WC); else thousands_sepwc = nl_langinfo_wc (_NL_MONETARY_THOUSANDS_SEP_WC); if (thousands_sepwc == L_('\0')) grouping = NULL; } else { if (info->extra == 0) thousands_sep = nl_langinfo (THOUSANDS_SEP); else thousands_sep = nl_langinfo (MON_THOUSANDS_SEP); if (*thousands_sep == '\0') grouping = NULL; } } } else#elif defined USE_NL_LANGINFO if (info->group && !wide) { if (info->extra == 0) grouping = nl_langinfo (GROUPING); else grouping = nl_langinfo (MON_GROUPING); if (*grouping <= 0 || *grouping == CHAR_MAX) grouping = NULL; else { /* Figure out the thousands separator character. */ if (info->extra == 0) thousands_sep = nl_langinfo (THOUSANDS_SEP); else thousands_sep = nl_langinfo (MON_THOUSANDS_SEP); if (*thousands_sep == '\0') grouping = NULL; } } else#elif defined USE_LOCALECONV if (info->group && !wide) { if (info->extra == 0) grouping = lc->grouping; else grouping = lc->mon_grouping; if (grouping == NULL || *grouping <= 0 || *grouping == CHAR_MAX) grouping = NULL; else { /* Figure out the thousands separator character. */ if (info->extra == 0) thousands_sep = lc->thousands_sep; else thousands_sep = lc->mon_thousands_sep; if (thousands_sep == NULL || *thousands_sep == '\0') grouping = NULL; } } else#endif grouping = NULL; if (grouping != NULL && !wide) /* If we are printing multibyte characters and there is a multibyte representation for the thousands separator, we must ensure the wide character thousands separator is available, even if it is fake. */ thousands_sepwc = (wchar_t) 0xfffffffe; /* Fetch the argument value. */ { memcpy (&fpnum, *(const void *const *) args[0], sizeof (fpnum)); /* Check for special values: not a number or infinity. */ if (isnanq (fpnum)) { ieee854_float128 u = { .value = fpnum }; is_neg = u.ieee.negative != 0; if (isupper (info->spec)) { special = "NAN"; wspecial = L_("NAN"); } else { special = "nan"; wspecial = L_("nan"); } } else if (isinfq (fpnum)) { is_neg = fpnum < 0; if (isupper (info->spec)) { special = "INF"; wspecial = L_("INF"); } else { special = "inf"; wspecial = L_("inf"); } } else { fracsize = mpn_extract_flt128 (fp_input, (sizeof (fp_input) / sizeof (fp_input[0])), &exponent, &is_neg, fpnum); to_shift = 1 + fracsize * BITS_PER_MP_LIMB - FLT128_MANT_DIG; } } if (special) { int width = info->width; if (is_neg || info->showsign || info->space) --width; width -= 3; if (!info->left && width > 0) PADN (' ', width); if (is_neg) outchar ('-'); else if (info->showsign) outchar ('+'); else if (info->space) outchar (' '); PRINT (special, wspecial, 3); if (info->left && width > 0) PADN (' ', width); return done; } /* We need three multiprecision variables. Now that we have the exponent of the number we can allocate the needed memory. It would be more efficient to use variables of the fixed maximum size but because this would be really big it could lead to memory problems. */ { mp_size_t bignum_size = ((ABS (exponent) + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB + (FLT128_MANT_DIG / BITS_PER_MP_LIMB > 2 ? 8 : 4)) * sizeof (mp_limb_t); frac = (mp_limb_t *) alloca (bignum_size); tmp = (mp_limb_t *) alloca (bignum_size); scale = (mp_limb_t *) alloca (bignum_size); } /* We now have to distinguish between numbers with positive and negative exponents because the method used for the one is not applicable/efficient for the other. */ scalesize = 0; if (exponent > 2) { /* |FP| >= 8.0. */ int scaleexpo = 0; int explog = FLT128_MAX_10_EXP_LOG; int exp10 = 0; const struct mp_power *powers = &_fpioconst_pow10[explog + 1]; int cnt_h, cnt_l, i; if ((exponent + to_shift) % BITS_PER_MP_LIMB == 0) { MPN_COPY_DECR (frac + (exponent + to_shift) / BITS_PER_MP_LIMB, fp_input, fracsize); fracsize += (exponent + to_shift) / BITS_PER_MP_LIMB; } else { cy = mpn_lshift (frac + (exponent + to_shift) / BITS_PER_MP_LIMB, fp_input, fracsize, (exponent + to_shift) % BITS_PER_MP_LIMB); fracsize += (exponent + to_shift) / BITS_PER_MP_LIMB; if (cy) frac[fracsize++] = cy; } MPN_ZERO (frac, (exponent + to_shift) / BITS_PER_MP_LIMB); assert (powers > &_fpioconst_pow10[0]); do { --powers; /* The number of the product of two binary numbers with n and m bits respectively has m+n or m+n-1 bits. */ if (exponent >= scaleexpo + powers->p_expo - 1) { if (scalesize == 0) { if (FLT128_MANT_DIG > _FPIO_CONST_OFFSET * BITS_PER_MP_LIMB) {#define _FPIO_CONST_SHIFT \ (((FLT128_MANT_DIG + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB) \ - _FPIO_CONST_OFFSET) /* 64bit const offset is not enough for IEEE quad long double. */ tmpsize = powers->arraysize + _FPIO_CONST_SHIFT; memcpy (tmp + _FPIO_CONST_SHIFT, &__tens[powers->arrayoff], tmpsize * sizeof (mp_limb_t));Lines 1–500 of 1318. Load more
/* Floating point output for `printf'. Copyright (C) 1995-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <float.h> #include <limits.h> #include <math.h> #include <string.h> #include <unistd.h> #include <stdlib.h> #include <stdbool.h> #define NDEBUG #include <assert.h> #ifdef HAVE_ERRNO_H #include <errno.h> #endif #include <stdio.h> #include <stdarg.h> #ifdef HAVE_FENV_H #include "quadmath-rounding-mode.h" #endif #include "quadmath-printf.h" #include "fpioconst.h" #ifdef USE_I18N_NUMBER_H #include "_i18n_number.h" #endif /* Macros for doing the actual output. */ #define outchar(ch) \ do \ { \ register const int outc = (ch); \ if (PUTC (outc, fp) == EOF) \ { \ if (buffer_malloced) \ free (wbuffer); \ return -1; \ } \ ++done; \ } while (0) #define PRINT(ptr, wptr, len) \ do \ { \ register size_t outlen = (len); \ if (len > 20) \ { \ if (PUT (fp, wide ? (const char *) wptr : ptr, outlen) != outlen) \ { \ if (buffer_malloced) \ free (wbuffer); \ return -1; \ } \ ptr += outlen; \ done += outlen; \ } \ else \ { \ if (wide) \ while (outlen-- > 0) \ outchar (*wptr++); \ else \ while (outlen-- > 0) \ outchar (*ptr++); \ } \ } while (0) #define PADN(ch, len) \ do \ { \ if (PAD (fp, ch, len) != len) \ { \ if (buffer_malloced) \ free (wbuffer); \ return -1; \ } \ done += len; \ } \ while (0) /* We use the GNU MP library to handle large numbers. An MP variable occupies a varying number of entries in its array. We keep track of this number for efficiency reasons. Otherwise we would always have to process the whole array. */ #define MPN_VAR(name) mp_limb_t *name; mp_size_t name##size #define MPN_ASSIGN(dst,src) \ memcpy (dst, src, (dst##size = src##size) * sizeof (mp_limb_t)) #define MPN_GE(u,v) \ (u##size > v##size || (u##size == v##size && mpn_cmp (u, v, u##size) >= 0)) extern mp_size_t mpn_extract_flt128 (mp_ptr res_ptr, mp_size_t size, int *expt, int *is_neg, __float128 value) attribute_hidden; static unsigned int guess_grouping (unsigned int intdig_max, const char *grouping); static wchar_t *group_number (wchar_t *buf, wchar_t *bufend, unsigned int intdig_no, const char *grouping, wchar_t thousands_sep, int ngroups); int __quadmath_printf_fp (struct __quadmath_printf_file *fp, const struct printf_info *info, const void *const *args) { /* The floating-point value to output. */ __float128 fpnum; /* Locale-dependent representation of decimal point. */ const char *decimal; wchar_t decimalwc; /* Locale-dependent thousands separator and grouping specification. */ const char *thousands_sep = NULL; wchar_t thousands_sepwc = L_('\0'); const char *grouping; /* "NaN" or "Inf" for the special cases. */ const char *special = NULL; const wchar_t *wspecial = NULL; /* We need just a few limbs for the input before shifting to the right position. */ mp_limb_t fp_input[(FLT128_MANT_DIG + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB]; /* We need to shift the contents of fp_input by this amount of bits. */ int to_shift = 0; /* The fraction of the floting-point value in question */ MPN_VAR(frac); /* and the exponent. */ int exponent; /* Sign of the exponent. */ int expsign = 0; /* Sign of float number. */ int is_neg = 0; /* Scaling factor. */ MPN_VAR(scale); /* Temporary bignum value. */ MPN_VAR(tmp); /* Digit which is result of last hack_digit() call. */ wchar_t last_digit, next_digit; bool more_bits; /* The type of output format that will be used: 'e'/'E' or 'f'. */ int type; /* Counter for number of written characters. */ int done = 0; /* General helper (carry limb). */ mp_limb_t cy; /* Nonzero if this is output on a wide character stream. */ int wide = info->wide; /* Buffer in which we produce the output. */ wchar_t *wbuffer = NULL; /* Flag whether wbuffer is malloc'ed or not. */ int buffer_malloced = 0; auto wchar_t hack_digit (void); wchar_t hack_digit (void) { mp_limb_t hi; if (expsign != 0 && type == 'f' && exponent-- > 0) hi = 0; else if (scalesize == 0) { hi = frac[fracsize - 1]; frac[fracsize - 1] = mpn_mul_1 (frac, frac, fracsize - 1, 10); } else { if (fracsize < scalesize) hi = 0; else { hi = mpn_divmod (tmp, frac, fracsize, scale, scalesize); tmp[fracsize - scalesize] = hi; hi = tmp[0]; fracsize = scalesize; while (fracsize != 0 && frac[fracsize - 1] == 0) --fracsize; if (fracsize == 0) { /* We're not prepared for an mpn variable with zero limbs. */ fracsize = 1; return L_('0') + hi; } } mp_limb_t _cy = mpn_mul_1 (frac, frac, fracsize, 10); if (_cy != 0) frac[fracsize++] = _cy; } return L_('0') + hi; } /* Figure out the decimal point character. */ #ifdef USE_NL_LANGINFO if (info->extra == 0) decimal = nl_langinfo (DECIMAL_POINT); else { decimal = nl_langinfo (MON_DECIMAL_POINT); if (*decimal == '\0') decimal = nl_langinfo (DECIMAL_POINT); } /* The decimal point character must never be zero. */ assert (*decimal != '\0'); #elif defined USE_LOCALECONV const struct lconv *lc = localeconv (); if (info->extra == 0) decimal = lc->decimal_point; else { decimal = lc->mon_decimal_point; if (decimal == NULL || *decimal == '\0') decimal = lc->decimal_point; } if (decimal == NULL || *decimal == '\0') decimal = "."; #else decimal = "."; #endif #ifdef USE_NL_LANGINFO_WC if (info->extra == 0) decimalwc = nl_langinfo_wc (_NL_NUMERIC_DECIMAL_POINT_WC); else { decimalwc = nl_langinfo_wc (_NL_MONETARY_DECIMAL_POINT_WC); if (decimalwc == L_('\0')) decimalwc = nl_langinfo_wc (_NL_NUMERIC_DECIMAL_POINT_WC); } /* The decimal point character must never be zero. */ assert (decimalwc != L_('\0')); #else decimalwc = L_('.'); #endif #if defined USE_NL_LANGINFO && defined USE_NL_LANGINFO_WC if (info->group) { if (info->extra == 0) grouping = nl_langinfo (GROUPING); else grouping = nl_langinfo (MON_GROUPING); if (*grouping <= 0 || *grouping == CHAR_MAX) grouping = NULL; else { /* Figure out the thousands separator character. */ if (wide) { if (info->extra == 0) thousands_sepwc = nl_langinfo_wc (_NL_NUMERIC_THOUSANDS_SEP_WC); else thousands_sepwc = nl_langinfo_wc (_NL_MONETARY_THOUSANDS_SEP_WC); if (thousands_sepwc == L_('\0')) grouping = NULL; } else { if (info->extra == 0) thousands_sep = nl_langinfo (THOUSANDS_SEP); else thousands_sep = nl_langinfo (MON_THOUSANDS_SEP); if (*thousands_sep == '\0') grouping = NULL; } } } else #elif defined USE_NL_LANGINFO if (info->group && !wide) { if (info->extra == 0) grouping = nl_langinfo (GROUPING); else grouping = nl_langinfo (MON_GROUPING); if (*grouping <= 0 || *grouping == CHAR_MAX) grouping = NULL; else { /* Figure out the thousands separator character. */ if (info->extra == 0) thousands_sep = nl_langinfo (THOUSANDS_SEP); else thousands_sep = nl_langinfo (MON_THOUSANDS_SEP); if (*thousands_sep == '\0') grouping = NULL; } } else #elif defined USE_LOCALECONV if (info->group && !wide) { if (info->extra == 0) grouping = lc->grouping; else grouping = lc->mon_grouping; if (grouping == NULL || *grouping <= 0 || *grouping == CHAR_MAX) grouping = NULL; else { /* Figure out the thousands separator character. */ if (info->extra == 0) thousands_sep = lc->thousands_sep; else thousands_sep = lc->mon_thousands_sep; if (thousands_sep == NULL || *thousands_sep == '\0') grouping = NULL; } } else #endif grouping = NULL; if (grouping != NULL && !wide) /* If we are printing multibyte characters and there is a multibyte representation for the thousands separator, we must ensure the wide character thousands separator is available, even if it is fake. */ thousands_sepwc = (wchar_t) 0xfffffffe; /* Fetch the argument value. */ { memcpy (&fpnum, *(const void *const *) args[0], sizeof (fpnum)); /* Check for special values: not a number or infinity. */ if (isnanq (fpnum)) { ieee854_float128 u = { .value = fpnum }; is_neg = u.ieee.negative != 0; if (isupper (info->spec)) { special = "NAN"; wspecial = L_("NAN"); } else { special = "nan"; wspecial = L_("nan"); } } else if (isinfq (fpnum)) { is_neg = fpnum < 0; if (isupper (info->spec)) { special = "INF"; wspecial = L_("INF"); } else { special = "inf"; wspecial = L_("inf"); } } else { fracsize = mpn_extract_flt128 (fp_input, (sizeof (fp_input) / sizeof (fp_input[0])), &exponent, &is_neg, fpnum); to_shift = 1 + fracsize * BITS_PER_MP_LIMB - FLT128_MANT_DIG; } } if (special) { int width = info->width; if (is_neg || info->showsign || info->space) --width; width -= 3; if (!info->left && width > 0) PADN (' ', width); if (is_neg) outchar ('-'); else if (info->showsign) outchar ('+'); else if (info->space) outchar (' '); PRINT (special, wspecial, 3); if (info->left && width > 0) PADN (' ', width); return done; } /* We need three multiprecision variables. Now that we have the exponent of the number we can allocate the needed memory. It would be more efficient to use variables of the fixed maximum size but because this would be really big it could lead to memory problems. */ { mp_size_t bignum_size = ((ABS (exponent) + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB + (FLT128_MANT_DIG / BITS_PER_MP_LIMB > 2 ? 8 : 4)) * sizeof (mp_limb_t); frac = (mp_limb_t *) alloca (bignum_size); tmp = (mp_limb_t *) alloca (bignum_size); scale = (mp_limb_t *) alloca (bignum_size); } /* We now have to distinguish between numbers with positive and negative exponents because the method used for the one is not applicable/efficient for the other. */ scalesize = 0; if (exponent > 2) { /* |FP| >= 8.0. */ int scaleexpo = 0; int explog = FLT128_MAX_10_EXP_LOG; int exp10 = 0; const struct mp_power *powers = &_fpioconst_pow10[explog + 1]; int cnt_h, cnt_l, i; if ((exponent + to_shift) % BITS_PER_MP_LIMB == 0) { MPN_COPY_DECR (frac + (exponent + to_shift) / BITS_PER_MP_LIMB, fp_input, fracsize); fracsize += (exponent + to_shift) / BITS_PER_MP_LIMB; } else { cy = mpn_lshift (frac + (exponent + to_shift) / BITS_PER_MP_LIMB, fp_input, fracsize, (exponent + to_shift) % BITS_PER_MP_LIMB); fracsize += (exponent + to_shift) / BITS_PER_MP_LIMB; if (cy) frac[fracsize++] = cy; } MPN_ZERO (frac, (exponent + to_shift) / BITS_PER_MP_LIMB); assert (powers > &_fpioconst_pow10[0]); do { --powers; /* The number of the product of two binary numbers with n and m bits respectively has m+n or m+n-1 bits. */ if (exponent >= scaleexpo + powers->p_expo - 1) { if (scalesize == 0) { if (FLT128_MANT_DIG > _FPIO_CONST_OFFSET * BITS_PER_MP_LIMB) { #define _FPIO_CONST_SHIFT \ (((FLT128_MANT_DIG + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB) \ - _FPIO_CONST_OFFSET) /* 64bit const offset is not enough for IEEE quad long double. */ tmpsize = powers->arraysize + _FPIO_CONST_SHIFT; memcpy (tmp + _FPIO_CONST_SHIFT, &__tens[powers->arrayoff], tmpsize * sizeof (mp_limb_t));