On 2012-10-25, Piet van Oostrum p...@vanoostrum.org wrote:
Adrien adnoth...@gmail.com writes:
print {:.3g}.format(2.356) # this rounds up
But:
print {:.3g}.format(12.356)
12.4
print {:.3g}.format(123.356)
123
The precision is a decimal number indicating how many digits
should be
Adrien adnoth...@gmail.com writes:
print {:.3g}.format(2.356) # this rounds up
But:
print {:.3g}.format(12.356)
12.4
print {:.3g}.format(123.356)
123
--
Piet van Oostrum p...@vanoostrum.org
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
--
Is there a way to specify to format I want a floating point written with no
more
than e.g., 2 digits after the decimal? I tried {:.2f}, but then I get all
floats written with 2 digits, even if they are 0:
2.35 yes, that's what I want
2.00 no, I want just 2 or 2.
--
On Mon, Oct 15, 2012 at 5:12 AM, Neal Becker ndbeck...@gmail.com wrote:
Is there a way to specify to format I want a floating point written with no
more
than e.g., 2 digits after the decimal? I tried {:.2f}, but then I get all
floats written with 2 digits, even if they are 0:
2.35 yes,
There doesn't seem to be any direct way to achieve this.
Maybe you can do something like this:
import math
x = 3.05
if math.modf(x)[0] != 0.0: print x
Cheers,
-Kamlesh
On Mon, Oct 15, 2012 at 5:59 PM, Chris Rebert c...@rebertia.com wrote:
On Mon, Oct 15, 2012 at 5:12 AM, Neal Becker
Le 15/10/2012 14:12, Neal Becker a écrit :
Is there a way to specify to format I want a floating point written with no more
than e.g., 2 digits after the decimal? I tried {:.2f}, but then I get all
floats written with 2 digits, even if they are 0:
2.35 yes, that's what I want
2.00 no, I want
On 10/15/2012 08:29 AM, Chris Rebert wrote:
On Mon, Oct 15, 2012 at 5:12 AM, Neal Becker ndbeck...@gmail.com wrote:
Is there a way to specify to format I want a floating point written with no
more
than e.g., 2 digits after the decimal? I tried {:.2f}, but then I get all
floats written with