diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-07-12 09:25:07 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2020-07-12 09:25:07 +0000 |
commit | 66a1282e4e7e96b71e2cfb45acc282a2040a7acb (patch) | |
tree | 39d6b05033785ad995eefec457d7e6a332b7bb78 /Build/source/libs/mpfr/mpfr-src/src/sub_ui.c | |
parent | cffbc490ae11d44a67e8890a76086448ff67e76b (diff) |
mpfr-4.1.0
git-svn-id: svn://tug.org/texlive/trunk@55817 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/sub_ui.c')
-rw-r--r-- | Build/source/libs/mpfr/mpfr-src/src/sub_ui.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/sub_ui.c b/Build/source/libs/mpfr/mpfr-src/src/sub_ui.c index bfea60c6895..936e1756d65 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/sub_ui.c +++ b/Build/source/libs/mpfr/mpfr-src/src/sub_ui.c @@ -1,6 +1,6 @@ /* mpfr_sub_ui -- subtract a floating-point number and a machine integer -Copyright 2000-2019 Free Software Foundation, Inc. +Copyright 2000-2020 Free Software Foundation, Inc. Contributed by the AriC and Caramba projects, INRIA. This file is part of the GNU MPFR Library. @@ -56,24 +56,38 @@ mpfr_sub_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mpfr_rnd_t rnd_mode /* Main code */ { - mpfr_t uu; - mp_limb_t up[1]; - int cnt; int inex; MPFR_SAVE_EXPO_DECL (expo); - MPFR_TMP_INIT1 (up, uu, GMP_NUMB_BITS); - MPFR_STAT_STATIC_ASSERT (MPFR_LIMB_MAX >= ULONG_MAX); - /* So, u fits in a mp_limb_t, which justifies the casts below. */ - MPFR_ASSERTD (u != 0); - count_leading_zeros (cnt, (mp_limb_t) u); - *up = (mp_limb_t) u << cnt; - /* Optimization note: Exponent save/restore operations may be removed if mpfr_sub works even when uu is out-of-range. */ MPFR_SAVE_EXPO_MARK (expo); - MPFR_SET_EXP (uu, GMP_NUMB_BITS - cnt); - inex = mpfr_sub (y, x, uu, rnd_mode); + +#ifdef MPFR_LONG_WITHIN_LIMB + { + mpfr_t uu; + mp_limb_t up[1]; + int cnt; + + MPFR_TMP_INIT1 (up, uu, GMP_NUMB_BITS); + /* So, u fits in a mp_limb_t, which justifies the casts below. */ + MPFR_ASSERTD (u != 0); + count_leading_zeros (cnt, (mp_limb_t) u); + up[0] = (mp_limb_t) u << cnt; + MPFR_SET_EXP (uu, GMP_NUMB_BITS - cnt); + inex = mpfr_sub (y, x, uu, rnd_mode); + } +#else + { + mpfr_t uu; + + mpfr_init2 (uu, sizeof (unsigned long) * CHAR_BIT); + mpfr_set_ui (uu, u, MPFR_RNDZ); + inex = mpfr_sub (y, x, uu, rnd_mode); + mpfr_clear (uu); + } +#endif + MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags); MPFR_SAVE_EXPO_FREE (expo); return mpfr_check_range (y, inex, rnd_mode); |