Re: Floating point "g" format not stripping trailing zeros

2015-02-14 Thread Ian Kelly
On Fri, Feb 13, 2015 at 6:22 PM, Mark Lawrence wrote: > On 14/02/2015 00:11, Ian Kelly wrote: >> >> On Fri, Feb 13, 2015 at 4:05 PM, Mark Lawrence >> 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 ind

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Gregory Ewing
Mark Lawrence 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 dec

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Mark Lawrence
On 14/02/2015 00:11, Ian Kelly wrote: On Fri, Feb 13, 2015 at 4:05 PM, Mark Lawrence 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 float

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 4:05 PM, Mark Lawrence 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

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Mark Lawrence
On 12/02/2015 23:46, Ian Kelly wrote: On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote: from decimal import Decimal as D x = D(1)/D(999) '{:.15g}'.format(x) '0.00100100100100100' [...] I'd say it's a bug. P is 15, you've got 17 digits after the decimal place and two of those are insign

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 2:40 PM, Ian Kelly wrote: > On Fri, Feb 13, 2015 at 2:22 PM, Grant Edwards > wrote: >> On 2015-02-13, Dave Angel wrote: >>> On the other hand, the Decimal package has a way that the programmer >>> can tell how many digits to use at each stage of the calculation. >> >> Th

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 2:22 PM, Grant Edwards wrote: > On 2015-02-13, Dave Angel wrote: >> On the other hand, the Decimal package has a way that the programmer >> can tell how many digits to use at each stage of the calculation. > > That's what surpised me. From TFM: > > https://docs.python.org

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Grant Edwards
On 2015-02-13, Dave Angel wrote: > On 02/13/2015 03:33 PM, Grant Edwards wrote: >> On 2015-02-13, Ian Kelly wrote: >> >>> Significant digits are within the precision of the calculation. >>> Writing 1.230 indicates that the fourth digit is known to be zero. >>> Writing 1.23 outside a context of ex

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Dave Angel
On 02/13/2015 03:33 PM, Grant Edwards wrote: On 2015-02-13, Ian Kelly wrote: Significant digits are within the precision of the calculation. Writing 1.230 indicates that the fourth digit is known to be zero. Writing 1.23 outside a context of exact calculation indicates that the fourth digit i

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 1:33 PM, Grant Edwards wrote: > On 2015-02-13, Ian Kelly wrote: >> On Fri, Feb 13, 2015 at 7:02 AM, Grant Edwards >> wrote: >>> On 2015-02-12, Ian Kelly wrote: On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote: > {:.15g} is supposed to give 15 digits o

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Grant Edwards
On 2015-02-13, Ian Kelly wrote: > On Fri, Feb 13, 2015 at 7:02 AM, Grant Edwards > wrote: >> On 2015-02-12, Ian Kelly wrote: >>> On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote: >>> {:.15g} is supposed to give 15 digits of precision, but with trailing zeros removed. >>> >>> The

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 7:02 AM, Grant Edwards wrote: > On 2015-02-12, Ian Kelly wrote: >> On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote: >> >>> {:.15g} is supposed to give 15 digits of precision, but with trailing >>> zeros removed. >> >> The doc says with "insignificant" trailing zeros

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Ian Kelly
On Fri, Feb 13, 2015 at 2:26 AM, Hrvoje Nikšić wrote: > Ian Kelly writes: >> When you specify the a precision of 15 in your format string, you're >> telling it to take the first 15 of those. It doesn't care that the >> last couple of those are zeros, because as far as it's concerned, >> those digi

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Grant Edwards
On 2015-02-12, Ian Kelly wrote: > On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote: > >> {:.15g} is supposed to give 15 digits of precision, but with trailing >> zeros removed. > > The doc says with "insignificant" trailing zeros removed, not all > trailing zeros. Can somebody explain the di

Re: Floating point "g" format not stripping trailing zeros

2015-02-13 Thread Hrvoje Nikšić
Ian Kelly writes: > When you specify the a precision of 15 in your format string, you're > telling it to take the first 15 of those. It doesn't care that the > last couple of those are zeros, because as far as it's concerned, > those digits are significant. OK, it's a bit surprising, but also cons

Re: Floating point "g" format not stripping trailing zeros

2015-02-12 Thread Ian Kelly
On Thu, Feb 12, 2015 at 1:23 PM, Hrvoje Nikšić wrote: >> > from decimal import Decimal as D >> > x = D(1)/D(999) >> > '{:.15g}'.format(x) >> >> >> >> '0.00100100100100100' > [...] >> > I'd say it's a bug. P is 15, you've got 17 digits after the decimal place >> > and two of those are

Re: Floating point "g" format not stripping trailing zeros

2015-02-12 Thread Hrvoje Nikšić
> > from decimal import Decimal as D > > x = D(1)/D(999) > > '{:.15g}'.format(x) > >> > >> '0.00100100100100100' [...] > > I'd say it's a bug. P is 15, you've got 17 digits after the decimal place > > and two of those are insignificant trailing zeros. > > Actually it's the float versio

Re: Floating point "g" format not stripping trailing zeros

2015-02-11 Thread Ian Kelly
On Wed, Feb 11, 2015 at 3:19 PM, Ian Kelly wrote: > On Wed, Feb 11, 2015 at 2:48 PM, Mark Lawrence > wrote: >> On 11/02/2015 20:02, Hrvoje Nikšić wrote: >>> >>> According to the documentation of the "g" floating-point format, >>> trailing zeros should be stripped from the resulting string: >>> >

Re: Floating point "g" format not stripping trailing zeros

2015-02-11 Thread Ian Kelly
On Wed, Feb 11, 2015 at 2:48 PM, Mark Lawrence wrote: > On 11/02/2015 20:02, Hrvoje Nikšić wrote: >> >> According to the documentation of the "g" floating-point format, >> trailing zeros should be stripped from the resulting string: >> >> """ >> General format. For a given precision p >= 1, this r

Re: Floating point "g" format not stripping trailing zeros

2015-02-11 Thread Mark Lawrence
On 11/02/2015 20:02, Hrvoje Nikšić wrote: According to the documentation of the "g" floating-point format, trailing zeros should be stripped from the resulting string: """ General format. For a given precision p >= 1, this rounds the number to p significant digits and then formats the result in

Floating point "g" format not stripping trailing zeros

2015-02-11 Thread Hrvoje Nikšić
According to the documentation of the "g" floating-point format, trailing zeros should be stripped from the resulting string: """ General format. For a given precision p >= 1, this rounds the number to p significant digits and then formats the result in either fixed-point format or in scientific n