From: Gavin Kistner Date: 2004-10-29T10:45:59+09:00 Subject: Re: Rounding error, (100.0 * 9.95).to_i == 994 On Oct 28, 2004, at 3:42 PM, Aredridel wrote: > I went about implementing one the other day, a subclass of BigDecimal, > and ran into a snag: SubclassOfBigdecimal.new always returns a > BigDecimal. It doesn't use initialize and alloc or any equivalent, > making subclassing next to impossible. This may be yet another case where the suggested way of implementing the class that is 'mostly a BigDecimal' is to wrap BigDecimal instances: class MyMoney def initialize( ... ) @internal_representation = BigDecimal.new( ... ) end def +( n ) MyMoney.new( @internal_representation + n ) end # etc. end