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
>> 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'
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
___
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