
30 Oct
2010
30 Oct
'10
10:45 p.m.
Hi. Below is a patch which makes rational.hpp use grouped arithmetic operators. While we are at it, use ordered_euclidean_ring_operators instead of just ordered_field_operators. While it might sound strange at first, mod can make sense even for rational numbers. For instance, Common Lisp, which has a native rational type, works fine if mod is used on rational numbers... template <typename IntType> rational<IntType>& rational<IntType>::operator%= (const rational<IntType>& r) { return *this -= r * floor(rational_cast<double>(*this / r)); } I am aware that the use of floor() is probably problematic. I am all open for comments and suggestions for improvements. -- Thanks, ⡍⠁⠗⠊⠕