diff options
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/cmp_ld.c')
-rw-r--r-- | Build/source/libs/mpfr/mpfr-src/src/cmp_ld.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/cmp_ld.c b/Build/source/libs/mpfr/mpfr-src/src/cmp_ld.c index d2eda97d09d..536316a182c 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/cmp_ld.c +++ b/Build/source/libs/mpfr/mpfr-src/src/cmp_ld.c @@ -20,6 +20,8 @@ along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include <float.h> /* needed so that MPFR_LDBL_MANT_DIG is correctly defined */ + #include "mpfr-impl.h" int @@ -33,9 +35,17 @@ mpfr_cmp_ld (mpfr_srcptr b, long double d) mpfr_init2 (tmp, MPFR_LDBL_MANT_DIG); res = mpfr_set_ld (tmp, d, MPFR_RNDN); + if (res != 0) /* can happen when "long double" is double-double */ + { + /* since the smallest value is 2^(-1074) and the largest is + < 2^1024, every double-double is exactly representable with + 1024 + 1074 bits */ + mpfr_set_prec (tmp, 1024 + 1074); + res = mpfr_set_ld (tmp, d, MPFR_RNDN); + } MPFR_ASSERTD (res == 0); - mpfr_clear_flags (); + MPFR_CLEAR_FLAGS (); res = mpfr_cmp (b, tmp); MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags); |