On Wed, 2009-06-03 at 19:36 +0200, Marnen Laibow-Koser wrote:
> Craig White wrote:
> > Thanks - I see said the blind man...
> > 
> > all I had to do was to first convert big decimal to float and then the
> > sprint function worked.
> > 
> > @price.to_f.to_fl(2) and I get what I wanted in the view...
> 
> Your Float#to_fl method is unnecessary and has semantics that will 
> confuse experienced Ruby programmers.  Try @price.round(2).to_f.
----
well, the round(2) function will return 1.5 if that is the stored value
in big decimal which was unacceptable but I didn't try
@price.round(2).to_f but I wonder which is faster/slower.

In reality, though, it tossed an error...

undefined method `round' for #<Price:0xb6e1bf20>

which I think is back to my original problem of having a big decimal,
that must be converted to a float before it can be rounded.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to