Floating point "g" format not stripping trailing zeros

Ian Kelly ian.g.kelly at gmail.com
Sat Feb 14 19:39:16 EST 2015


On Fri, Feb 13, 2015 at 6:22 PM, Mark Lawrence <breamoreboy at yahoo.co.uk> wrote:
> On 14/02/2015 00:11, Ian Kelly wrote:
>>
>> 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".
>>
>
> With insignificant trailing zeros removed.  So if I'm asking for 15
> significant digits *in the output* I don't expect to see those zeros as I
> don't see them as significant.  If I did I'd have p set higher.

So you think you should have to request 17 significant digits in order
to have 15 of them included?



More information about the Python-list mailing list