--oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 11, 2011 at 03:11:14PM +0900, Kenta Murata wrote: > Hi, > > 2011/1/11 Aaron Patterson <aaron / tenderlovemaking.com>: > > On Tue, Jan 11, 2011 at 01:23:47PM +0900, Kenta Murata wrote: > >> Hi Aaron and Matz, > >> > >> 2011/1/11 Yukihiro Matsumoto <matz / ruby-lang.org>: > >> > Hi, > >> > > >> > In message "Re: [ruby-core:34318] ext/bigdecimal/lib/bigdecimal/util.rb" > >> > on Tue, 11 Jan 2011 09:17:15 +0900, Aaron Patterson <aaron / tenderlovemaking.com> writes: > >> > > >> > |It looks like ext/bugdecimal/lib/bigdecimal/util.rb is only > >> > |conditionally required by bigdecimal.c: > >> > | > >> > | https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L148-151 > >> > | > >> > |Could we possibly change this to just require 'util.rb' all the time? > >> > > >> > I'd rather like to remove the dependency of util.rb from the > >> > bigdecimal core. > >> > >> I've wrote an another patch without requiring bigdecimal/util.rb. > >> > >> https://gist.github.com/774012 > >> > >> If it doesn't have any problems, I'll commit tonight. > > > > This doesn't do what I want. I want a generic way to convert Numeric > > types to BigDecimal. > > > > util.rb half-way implements Numeric => BigDecimal conversion. See > > [ruby-core:34326] for examples. > > > > If you like, I can write tests along with a patch to demonstrate. :-) > > https://gist.github.com/774077 > > This patch support to generate a BigDecimal > from any Numeric classes excepting Float. Yes, this is what I want (plus Float support ;-) ). > Float is difficult. > The radix of Float may be different from BigDecimal so some Floats > aren't able to convert to BigDecimal without error. > For example 10.1 isn't represented in Float precisely: > > 10.1.to_r #=> (5685794529555251/562949953421312) > > This is not 10.1. > You have to specify a precision for conversion if you convert > 10.1 to BigDecimal. > For any Float values, we have to specify precisions for converting > to BigDecimal. True, but we still have this problem with String => BigDecimal. > I'll implement that, please wait to finish, or please give me a patch. Excellent. I will try to implement a patch, but don't wait for me. Thank you very much for the prompt response! I really appreciate it. -- Aaron Patterson http://tenderlovemaking.com/ --oyUTqETQ0mS9luUI Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJNLANQAAoJEJUxcLy0/6/GNgsH/29eZNkyBRnrD4PcYVY1jQzg 7zsa/Fd4uEnapfKfC5SFvr7RFkhYqW/SuWlDyVs4OMnd9wjBGXYcvmA8U2q3RJBz z4/EN49bUjynHO8bgpq46x+w6AyGlpsRQTjXwntlor1fnJzhUXpUUnDv/A8mk/dV GLHNyXRCE4seZbunj+Dys+zcSqnoZhfrr29CFqK1UPLtcfKVJ8kpxiqDC1KXdYvn E9aj4iIJfw3/t/uKxcCDLRBEmw3AHUPH/Za0m5NGHdzMxjwDbMrVH2J1RLM+UrCk nFV9Q+dfDT0FlSmJVUblQVNW2ScI8X49E1iv7E59WSIvl41A4Ol1NYuZ9UzhIUMk -----END PGP SIGNATURE----- --oyUTqETQ0mS9luUI--