Boost logo

Boost :

From: Moore, Paul (paul.moore_at_[hidden])
Date: 2002-02-21 11:16:02


Can the following fix be applied to rational.hpp and rational_test.cpp?

Thanks,
Paul.

--- boost_1_27_0\boost\rational.hpp.orig Thu Feb 21 16:09:11 2002
+++ boost_1_27_0\boost\rational.hpp Thu Feb 21 16:09:27 2002
@@ -298,6 +298,11 @@
     IntType gcd2 = gcd<IntType>(r_den, den);
     num = (num/gcd1) * (r_den/gcd2);
     den = (den/gcd2) * (r_num/gcd1);
+
+ if (den < zero) {
+ num = -num;
+ den = -den;
+ }
     return *this;
 }
 
--- boost_1_27_0\libs\rational\rational_test.cpp.orig Thu Feb 21 16:17:09
2002
+++ boost_1_27_0\libs\rational\rational_test.cpp Thu Feb 21 16:17:17
2002
@@ -280,6 +280,7 @@
     CHECK(( r0 == rat(16,15) ));
     r0 /= 4;
     CHECK(( r0 == rat(4,15) ));
+ CHECK(( rat(-1)/rat(-3) == rat(1,3) ));
 
     /* tests for operations on self */
     r0 = rat(4,3);


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk