From: mathew Date: 2011-01-13T01:35:40+09:00 Subject: [ruby-core:34442] Re: ext/bigdecimal/lib/bigdecimal/util.rb On Tue, Jan 11, 2011 at 01:14, Aaron Patterson wrote: > On Tue, Jan 11, 2011 at 03:11:14PM +0900, Kenta Murata wrote: >> 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. Eh? Surely any string will have finite length, and hence a finite base-10 representation. Thus it can convert to a BigDecimal without error. We're only talking about strings containing base-10 numbers, right? mathew