From 8e26eb9395b5ff938ef4f50dd832aad6b4b059d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Pe=C3=B1aranda?= Date: Wed, 8 Aug 2012 15:16:49 +0000 Subject: [PATCH] bug in Gmpfr input from istream --- Number_types/include/CGAL/GMP/Gmpfr_type.h | 5 +++++ Number_types/test/Number_types/Gmpfr.cpp | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Number_types/include/CGAL/GMP/Gmpfr_type.h b/Number_types/include/CGAL/GMP/Gmpfr_type.h index a1449d20fc9..ed5e56aaf72 100644 --- a/Number_types/include/CGAL/GMP/Gmpfr_type.h +++ b/Number_types/include/CGAL/GMP/Gmpfr_type.h @@ -1082,6 +1082,11 @@ std::istream& operator>>(std::istream& is,Gmpfr &f){ mant=10*mant+(c-'0'); c=is.get(); } + + // set the correct sign of the mantissa + if(neg_mant) + mant=-mant; + is.putback(c); gmpz_eat_white_space(is); diff --git a/Number_types/test/Number_types/Gmpfr.cpp b/Number_types/test/Number_types/Gmpfr.cpp index e1c1b5d0f96..c66fe477364 100644 --- a/Number_types/test/Number_types/Gmpfr.cpp +++ b/Number_types/test/Number_types/Gmpfr.cpp @@ -207,7 +207,8 @@ int main(){ CGAL::Gmpzf f; mpfr_set_inf(plus_infinity.fr(),1); mpfr_set_inf(minus_infinity.fr(),-1); - _TEST("I/O int",(CGAL::test_io(2145338339));) + _TEST("I/O positive int",(CGAL::test_io(2145338339));) + _TEST("I/O negative int",(CGAL::test_io(-25295236));) _TEST("I/O double",(CGAL::test_io(.2147483647));) _TEST("I/O +inf",(CGAL::test_io(plus_infinity));) _TEST("I/O -inf",(CGAL::test_io(minus_infinity));)