Just FYI: If you see only one decimal place inside of a form field, you
might want to look at the precision (number of decimal places) in your
database. For example, MySQL defaults to 1 for floats. As soon as you change
the precision to 2, you''ll see 2 places. This is, of course, only when
using <%=text_field %> and similar.
On 6/30/06, Pete <pertl@gmx.org> wrote:>
> sprintf("%.2f", number)
>
> just an idea:
>
> class Float
> def to_s(digits)
> sprintf("%.#{digits}f", self)
> end
> end
>
> 12.0.to_s(2)
>
> > 12.00
>
>
>
> ss schrieb:
> > Hi,
> >
> > I have a float that often looks like somthing like 2003.2 in my
> > controller (1 decimal place)
> >
> > Is there a way to always show it to 2 decimal places eg 2003.20 ?
> >
> > Thanks
> > Scott
> >
> >
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060630/9037466b/attachment.html