From ac22346b43562c08625ed4a0b56cd6751d97ec83 Mon Sep 17 00:00:00 2001 From: Rune Zedeler Date: Tue, 23 Oct 2007 06:26:35 +0200 Subject: [PATCH] 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. --- flower/rational.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- 2.39.2