Re: Remove trailing zeros

northband_101
Thu, 12 Mar 2009 14:12:01 -0000

Thanks Matt - I''ll try this out.

Best,
NB

On Feb 27, 4:33 pm, Matt Jones
<al2o...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> The %g specifier to sprintf will do this automatically:
>
> "%g" % 1.0
> => "1"
>
> "%g" % 1.375
> => "1.375"
>
> --Matt Jones
>
> 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.