From: Rune Zedeler Date: Tue, 23 Oct 2007 04:26:35 +0000 (+0200) Subject: Bugfix: Rational.cc: Modulo and trunc did not work with negative numbers. X-Git-Tag: release/2.11.35-1~76^2~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ac22346b43562c08625ed4a0b56cd6751d97ec83;p=lilypond.git Bugfix: Rational.cc: Modulo and trunc did not work with negative numbers. This is a library fix that did not show any bugs in lilypond - because lilypond does not use modulus of negative rationals. --- diff --git a/flower/rational.cc b/flower/rational.cc index 724f0d99ca..4205b1d683 100644 --- a/flower/rational.cc +++ b/flower/rational.cc @@ -50,7 +50,9 @@ Rational::abs () const Rational Rational::trunc_rat () const { - return Rational (num_ - (num_ % den_), den_); + if (is_infinity()) + return *this; + return Rational ((num_ - (num_ % den_)) * sign_, den_); } Rational::Rational () @@ -79,6 +81,7 @@ void Rational::set_infinite (int s) { sign_ = ::sign (s) * 2; + num_ = 1; } Rational