On Wed, 2009-06-03 at 07:07 +0200, Marnen Laibow-Koser wrote:
> Craig White wrote:
> [...]
> > NoMethodError: undefined method `to_fl' for
> > #<BigDecimal:b794c0fc,'0.115E1',8(12)>
> > from (irb):30
> > from :0
> >
> > How do I get the float value of 'big decimal' ?
> >
>
> Perhaps you should have checked the class documentation for BigDecimal
> (part of the Ruby standard library). If I remember correctly,
> BigDecimal#to_f will do what you want.
>
> to_f is the standard name for such methods; to_fl is idiosyncratic, and
> will cause problems if the consumers of your API expect to_f.
----
yeah, I'm sort of stuck in a rails 1.2.x time warp and am struggling
with a bunch of the changes in 2.3.x - thus, it wasn't really the big
decimal thing of mysql that was the problem.
I forgot about to_f because frankly, I never used it. I primarily am
concerned with view code here so I had just stuck that code to extend
the Float class (which worked so well in 1.2.x)...
class Float
def to_fl(digits)
sprintf("%.#{digits}f",self)
end
end
and I could get a fixed number of digits whenever I wanted. Apparently
this is like a very ineffective way to go about things in 2.3.x and to_f
gives me whatever decimal places it believes are significant so I'm sort
of trying to figure out how to locate the magic genie again.
Craig
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---