Re: [Tutor] cut all decimal places with zeros

2008-04-15 Thread John Fouhy
On 16/04/2008, Tim Michelsen <[EMAIL PROTECTED]> wrote: > Kent wrote: > > I don't know how to do this with just string formatting but I think > > ('%.4f' % n).rstrip('.0') > > will do what you want. > > No. > I tested with > n = 10.0 > You code returns '1' > > My code returns '10' Good catc

Re: [Tutor] cut all decimal places with zeros

2008-04-15 Thread Tim Michelsen
>> how can I suppress the decimal places for (only those) numbers whos >> decimal places are zero (0)? > > I don't know how to do this with just string formatting but I think > ('%.4f' % n).rstrip('.0') > will do what you want. No. I tested with n = 10.0 You code returns '1' My code returns '10'

Re: [Tutor] cut all decimal places with zeros

2008-04-14 Thread Kent Johnson
Tim Michelsen wrote: > Hello, > how can I suppress the decimal places for (only those) numbers whos > decimal places are zero (0)? I don't know how to do this with just string formatting but I think ('%.4f' % n).rstrip('.0') will do what you want. Kent ___

[Tutor] cut all decimal places with zeros

2008-04-14 Thread Tim Michelsen
Hello, how can I suppress the decimal places for (only those) numbers whos decimal places are zero (0)? Example: CODE In [1]: m = 2.0 In [2]: n = 2.56789080 In [3]: n_format = '%.4f' %n In [4]: n_format Out[4]: '2.5679' In [5]: m_format = '%.4f' %m In [6]: m_format Out[6]: '2.00