From: Michael Guterl Date: 2008-09-26T04:04:37+09:00 Subject: Re: Bug in the money gem? On Thu, Sep 25, 2008 at 2:34 PM, Eric LIn wrote: > For anyone of you using the money gem (http://dist.leetsoft.com/api/ > money/), I noticed today that 0 - 100 does not equal -100, it equals > 100 instead (all numbers here represent Money objects). Do any of you > find that odd? > I'm not sure, but it seems a bit strange. Here is the offending code: # File lib/money/money.rb, line 79 79: def -(other_money) 80: return other_money.dup if cents.zero? 81: return dup if other_money.cents.zero? 82: 83: if self.cents == 0 or currency == other_money.currency 84: Money.new(cents - other_money.cents, other_money.currency) 85: else 86: Money.new(cents - other_money.exchange_to(currency).cents, currency) 87: end 88: end I think the first return would make sense if the other_money variable had a negative value associated with it, however, other_money's value is not negative. HTH, Michael Guterl