--e0cb4efe358472d99a04bd95b23d
Content-Type: text/plain; charset=UTF-8
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.
--e0cb4efe358472d99a04bd95b23d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div>http://stdlib.rubyonrails.org/libdoc/bigdecimal/rdoc/index.html</div><div><br></div><div>&gt; String#</div><div>&gt; to_dC2 ... to BigDecimal</div>
<div>&gt;</div><div>&gt; Float#</div><div>&gt; to_d ... to BigDecimal</div><div>&gt;</div><div>&gt; Rational#</div><div>&gt; to_d ... to BigDecimal</div><div><br></div><div>These all exist... why not for Fixnum#to_d? Right now I&#39;m having to write a mixin on Fixnum, something like this:</div>
<div><br></div><div>class Fixnum</div><div> def to_d</div><div> BigDecimal(self.to_s)</div><div> end</div><div>end</div><div><br></div><div>The above code is *very* similar to what has been written for Float and String.</div>
<div><br></div><div>Is there a reason why this doesn&#39;t exist on Fixnum?&#39;m currently using 1.8.7.</div>
--e0cb4efe358472d99a04bd95b23d--