From ddc70eb66cc9f30d74826b51d72ecb52782d787a Mon Sep 17 00:00:00 2001 From: Michael Hemmer Date: Wed, 13 Jul 2011 12:57:50 +0000 Subject: [PATCH] the ultimate fix --- Number_types/include/CGAL/Root_of_traits.h | 6 +++--- Number_types/include/CGAL/Test/test_root_of_traits.h | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Number_types/include/CGAL/Root_of_traits.h b/Number_types/include/CGAL/Root_of_traits.h index 9756241ee04..d8cc003b279 100644 --- a/Number_types/include/CGAL/Root_of_traits.h +++ b/Number_types/include/CGAL/Root_of_traits.h @@ -70,11 +70,11 @@ solve_1(const NT &a_, const NT &b_, const NT &c_, OutputIterator oit) Root_of_1 a(cast(a_)), b(cast(b_)), c(cast(c_)); if ( a != 0 ) { - Root_of_1 a0_ (-b/2*a); + Root_of_1 a0_ (-b/(2*a)); Root_of_1 root_(CGAL_NTS square(a0_) - c/a); switch(CGAL::sign(root_)){ case CGAL::NEGATIVE: return oit; - case CGAL::ZERO: return *oit++ = Root_of_2(a0_); + case CGAL::ZERO: *oit++ = Root_of_2(a0_); return oit; default: // two roots *oit++ = make_root_of_2(a0_,Root_of_1(-1),root_); @@ -83,7 +83,7 @@ solve_1(const NT &a_, const NT &b_, const NT &c_, OutputIterator oit) } } else { - return *oit++ = -c/b; + *oit++ = -c/b; return oit; } } diff --git a/Number_types/include/CGAL/Test/test_root_of_traits.h b/Number_types/include/CGAL/Test/test_root_of_traits.h index c1c20beb7a4..ef3347f2f31 100644 --- a/Number_types/include/CGAL/Test/test_root_of_traits.h +++ b/Number_types/include/CGAL/Test/test_root_of_traits.h @@ -87,6 +87,12 @@ void test_root_of_traits(){ assert(roots.size()==2); assert(roots[0]==-CGAL::make_sqrt(T(2)) || is_not_exact ); assert(roots[1]== CGAL::make_sqrt(T(2)) || is_not_exact ); + } + { + Root_of_2 roots[2]= {Root_of_2(1),Root_of_2(1)}; + CGAL::solve_1(T(13),T(4),T(-23),roots); + assert(roots[0]==CGAL::make_root_of_2(T(13),T(4),T(-23),true) || is_not_exact ); + assert(roots[1]==CGAL::make_root_of_2(T(13),T(4),T(-23),false) || is_not_exact ); } { std::vector roots;