Re: Remove trailing zeros

northband_101
Fri, 27 Feb 2009 20:29:21 -0000

Thanks - this seems easy enough.



On Feb 27, 3:12 pm, pepe <P...-1PhG29ZdMB/g+20BJ0uB2w@public.gmane.org>
wrote:
> Maybe you can convert them to integers?
>
> my_float = 2.0
> my_float = my_float.to_i if my_float == my_float.to_i
>
> Pepe
>
> On Feb 27, 1:20 am, northband
<northb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > Hi -
>
> > I am working with floats and am wondering how I can trim the decimal
> > and trailing zeros on my whole numbers.  For instance, whole numbers
> > are being displayed as 1.0, 2.0, 3.0, etc...  I would like to remove
> > the decimal and any trailing zeros with out effecting other non-whole
> > number floats (ex. 1.375).
>
> > Any ideas?  Help appreciated.