From: Mark Campbell Date: 2012-04-14T07:23:34+09:00 Subject: Re: Why doesn't Fixnum#to_d exist? --e0cb4efe358416af8804bd96ebc7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Yes, that file has the String#to_d, Float#to_d and Rational#to_d. Fixnum#to_d is not present. 2012/4/13 Bartosz Dziewo=C5=84ski > It does exist, but it's in a separate file - bigdecimal/util or utils, > if I remember correctly. (I'm on my mobile, can't check.) > > 2012/4/13, Mark Campbell : > > http://stdlib.rubyonrails.org/libdoc/bigdecimal/rdoc/index.html > > > >> String# > >> to_d ... to BigDecimal > >> > >> Float# > >> to_d ... to BigDecimal > >> > >> Rational# > >> to_d ... to BigDecimal > > > > These all exist... why not for Fixnum#to_d? Right now I'm having to > write a > > mixin on Fixnum, something like this: > > > > class Fixnum > > def to_d > > BigDecimal(self.to_s) > > end > > end > > > > The above code is *very* similar to what has been written for Float and > > String. > > > > Is there a reason why this doesn't exist on Fixnum? I'm currently using > > 1.8.7. > > > > > -- > -- Matma Rex > > --e0cb4efe358416af8804bd96ebc7 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Yes, that file has the String#to_d, Float#to_d and Rational#to_d. Fixnum#to= _d is not present.

2012/4/13 Bartosz Dzie= wo=C5=84ski <ma= tma.rex@gmail.com>
It does exist, but it's in a separate fi= le - bigdecimal/util or utils,
if I remember correctly. (I'm on my mobile, can't check.)

2012/4/13, Mark Campbell <nitrodi= st@gmail.com>:
> http://stdl= ib.rubyonrails.org/libdoc/bigdecimal/rdoc/index.html
>
>> =C2=A0String#
>> =C2=A0 =C2=A0to_d =C2=A0 =C2=A0 =C2=A0... to BigDecimal
>>
>> =C2=A0Float#
>> =C2=A0 =C2=A0to_d =C2=A0 =C2=A0 =C2=A0... to BigDecimal
>>
>> =C2=A0Rational#
>> =C2=A0 =C2=A0to_d =C2=A0 =C2=A0 =C2=A0... to BigDecimal
>
> These all exist... why not for Fixnum#to_d? Right now I'm having t= o write a
> mixin on Fixnum, something like this:
>
> class Fixnum
> =C2=A0 def =C2=A0to_d
> =C2=A0 =C2=A0 BigDecimal(self.to_s)
> =C2=A0 end
> end
>
> The above code is *very* similar to what has been written for Float an= d
> String.
>
> Is there a reason why this doesn't exist on Fixnum? I'm curren= tly using
> 1.8.7.
>


--
-- Matma Rex


--e0cb4efe358416af8804bd96ebc7--