Floating point "g" format not stripping trailing zeros

Ian Kelly ian.g.kelly at gmail.com
Fri Feb 13 19:11:01 EST 2015


On Fri, Feb 13, 2015 at 4:05 PM, Mark Lawrence <breamoreboy at yahoo.co.uk> wrote:
> I still think it's a bug as the 'p' being referred to in the OP's original
> message is "The precision is a decimal number indicating how many digits
> should be displayed after the decimal point for a floating point value
> formatted with 'f' and 'F', or before and after the decimal point for a
> floating point value formatted with 'g' or 'G'".  In other words is has
> nothing to do with the precision of the underlying number.

I read that paragraph as describing generally what the precision
means, with the table below detailing more specifically how it is
used. I think for 'g' this is just trying to contrast it with 'f'
where it really is just the number of digits displayed after the
decimal point. The table entry for 'g' on the other hand quite clearly
says, "for a given precision p >= 1, this rounds the number to p
significant digits".



More information about the Python-list mailing list