From: Wilson Bilkovich Date: 2007-09-27T23:10:51+09:00 Subject: Re: Bug in BigDecimal#round ? On 9/27/07, Jano Svitok wrote: > On 9/27/07, Ryan Platte wrote: > > On Sep 27, 6:25 am, "Jano Svitok" wrote: > > > > It seems to me as a bug. The code in trunk is the same, so I guess > > > > it's not fixed yet. > > > > > > reported as #14271 > > > > Thank you very much for reporting the bug. > > I guess you can workaround the bug until it gets properly fixed - by > opening the BigDecimal class. Last night I could not come with > anything reasonable though ;-) > > class BigDecimal > alias_method :old_round, :round > def round(*args) > if XXX > self.class.new(YYY) > else > old_round(*args) > end > end > end > > the problematic parts are XXX and YYY... ;-) > args[0] and self.exponent might be usable... > > I haven't found any unit tests for BigDecimal, so if you create some, > please post them somewhere (I'm not sure where - possible choises are: > ruby tracker, http://rubyforge.org/projects/bfts/ tracker, ruby-core > mailing list) > JRuby has some: http://svn.codehaus.org/jruby/trunk/jruby/test/test_big_decimal.rb If you come up with some more, you could either submit them as a patch there, or post them to ruby-core. When we get around to BigDecimal in Rubinius, we will probably use the JRuby test case as a starting point, and then fill in any gaps we find. If you've posted some of them to ruby-core, that makes life easier.