From: Mark Thomas Date: 2008-09-26T03:44:41+09:00 Subject: Re: Bug in the money gem? On Sep 25, 2:32 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? Yes, it's odd. The problem is line 80: # 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 Try commenting line 80 out. I don't see any reason why the class wouldn't handle negative values, though I didn't look carefully. -- Mark.