Re: Engineering numerical format PEP discussion

2010-05-17 Thread Eike Welk
Keith wrote: > I am considering writing a PEP for the inclusion of an engineering > format specifier, and would appreciate input from others. I think it's a good idea. I regularly type numbers into my pocket calculator just to do this conversion. Eike. -- http://mail.python.org/mailman/listi

Re: Engineering numerical format PEP discussion

2010-04-27 Thread Keith
On Apr 27, 9:03 am, Mark Dickinson wrote: > On Apr 27, 2:16 am, Keith wrote: > > > On Apr 26, 8:47 pm, MRAB wrote: > > > > "t" for "powers of a thousand", perhaps? (Or "m"?) > > > Both of those letters are fine.  I kinda like "m" for the whole Greco- > > Roman angle, now that you point it out :-

Re: Engineering numerical format PEP discussion

2010-04-27 Thread cassiope
On Apr 25, 10:19 pm, Chris Rebert wrote: > On Sun, Apr 25, 2010 at 9:42 PM, Keith wrote: > > On Apr 26, 12:02 am, Chris Rebert wrote: > >> On Sun, Apr 25, 2010 at 8:36 PM, Keith wrote: > >> > I am considering writing a PEP for the inclusion of an engineering > >> > format specifier, and would a

Re: Engineering numerical format PEP discussion

2010-04-27 Thread Mark Dickinson
On Apr 27, 2:16 am, Keith wrote: > On Apr 26, 8:47 pm, MRAB wrote: > > > "t" for "powers of a thousand", perhaps? (Or "m"?) > > Both of those letters are fine.  I kinda like "m" for the whole Greco- > Roman angle, now that you point it out :-) By the way, there's already a feature request open f

Re: Engineering numerical format PEP discussion

2010-04-27 Thread Gregory Ewing
Keith wrote: I kinda like "m" for the whole Greco- Roman angle, now that you point it out :-) I like "m", too. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Engineering numerical format PEP discussion

2010-04-27 Thread Lie Ryan
On 04/27/10 10:47, MRAB wrote: > Mark Dickinson wrote: >> On Apr 26, 4:36 am, Keith wrote: >>> I am considering writing a PEP for the inclusion of an engineering >>> format specifier, and would appreciate input from others. >> >>> [...] >> >>> I am thinking that if we simply added something like %

Re: Engineering numerical format PEP discussion

2010-04-27 Thread Lie Ryan
On 04/27/10 10:36, Keith wrote: > I think it's worth making the print statement (or print function, as > the case may be) let us do engineering notation, just like it lets us > specify scientific notation. The print statement/function does no magic at all in specifying how numbers look like when.

Re: Engineering numerical format PEP discussion

2010-04-26 Thread Keith
On Apr 26, 8:47 pm, MRAB wrote: > "t" for "powers of a thousand", perhaps? (Or "m"?) Both of those letters are fine. I kinda like "m" for the whole Greco- Roman angle, now that you point it out :-) --Keith Brafford -- http://mail.python.org/mailman/listinfo/python-list

Re: Engineering numerical format PEP discussion

2010-04-26 Thread Keith
On Apr 26, 7:56 pm, Mark Dickinson wrote: > On Apr 26, 6:47 am, Keith wrote: > > > From that document it appears that my decimal.Decimal(1234567) example > > shows that the module has a bug: > > > Doc says: > > [0,123,3] ===>  "123E+3" > > > But Python does:>>> import decimal > > >>> decimal.Deci

Re: Engineering numerical format PEP discussion

2010-04-26 Thread MRAB
Mark Dickinson wrote: On Apr 26, 4:36 am, Keith wrote: I am considering writing a PEP for the inclusion of an engineering format specifier, and would appreciate input from others. [...] I am thinking that if we simply added something like %n (for eNgineer) to the list of format specifiers

Re: Engineering numerical format PEP discussion

2010-04-26 Thread Keith
On Apr 26, 5:33 am, Stefan Krah wrote: > Keith wrote: > > Even though this uses the to_eng_string() function, and even though I > > am using the decimal.Context class: > > > >>> c = decimal.Context(prec=5) > > >>> decimal.Decimal(1234567).to_eng_string(c) > > '1234567' > > > That is not an engine

Re: Engineering numerical format PEP discussion

2010-04-26 Thread Keith
>Apparently either you and the General Decimal Arithmetic spec differ >on what constitutes engineering notation, there's a bug in the Python >decimal library, You've distilled it precisely, and as you've shown in a different post, it's the former. The Python decimal module seems to implement corr

Re: Engineering numerical format PEP discussion

2010-04-26 Thread Mark Dickinson
On Apr 26, 6:47 am, Keith wrote: > From that document it appears that my decimal.Decimal(1234567) example > shows that the module has a bug: > > Doc says: > [0,123,3] ===>  "123E+3" > > But Python does:>>> import decimal > >>> decimal.Decimal(123000).to_eng_string() > > '123000' That's not a bug.

Re: Engineering numerical format PEP discussion

2010-04-26 Thread Mark Dickinson
On Apr 26, 4:36 am, Keith wrote: > I am considering writing a PEP for the inclusion of an engineering > format specifier, and would appreciate input from others. > [...] > I am thinking that if we simply added something like %n (for eNgineer) > to the list of format specifiers that we could make

Re: Engineering numerical format PEP discussion

2010-04-26 Thread Grant Edwards
On 2010-04-26, Keith wrote: > I am considering writing a PEP for the inclusion of an engineering > format specifier, and would appreciate input from others. I very regularly do something similar in various apps, though I often want to specify the exponent (e.g. I always want to print a given val

Re: Engineering numerical format PEP discussion

2010-04-26 Thread Stefan Krah
Keith wrote: > Even though this uses the to_eng_string() function, and even though I > am using the decimal.Context class: > > >>> c = decimal.Context(prec=5) > >>> decimal.Decimal(1234567).to_eng_string(c) > '1234567' > > That is not an engineering notation string. To clarify further: The spec

Re: Engineering numerical format PEP discussion

2010-04-26 Thread Stefan Krah
Chris Rebert wrote: > c = decimal.Context(prec=5) > decimal.Decimal(1234567).to_eng_string(c) > > '1234567' > > > > That is not an engineering notation string. > > Apparently either you and the General Decimal Arithmetic spec differ > on what constitutes engineering notation, there's a

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Terry Reedy
On 4/25/2010 11:36 PM, Keith wrote: I am considering writing a PEP for the inclusion of an engineering format specifier, and would appreciate input from others. I tested that input is no problem, so the only question is output. Do you think this idea has enough merit to make it to PEP status?

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Xavier Ho
On Mon, Apr 26, 2010 at 3:39 PM, Chris Rebert wrote: > "The conversion **exactly follows the rules for conversion to > scientific numeric string** except in the case of finite numbers > **where exponential notation is used.**" > Well, then maybe the conversion doesn't exactly follow the rules, i

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Keith
On Apr 26, 1:19 am, Chris Rebert wrote: > Apparently either you and the General Decimal Arithmetic spec differ > on what constitutes engineering notation, there's a bug in the Python > decimal library, or you're hitting some obscure part of the spec's > definition. snip > The spec:http://speleotro

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Chris Rebert
On Sun, Apr 25, 2010 at 10:25 PM, Xavier Ho wrote: > On Mon, Apr 26, 2010 at 3:19 PM, Chris Rebert wrote: >> Apparently either you and the General Decimal Arithmetic spec differ >> on what constitutes engineering notation, there's a bug in the Python >> decimal library, or you're hitting some obs

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Xavier Ho
On Mon, Apr 26, 2010 at 3:19 PM, Chris Rebert wrote: > Apparently either you and the General Decimal Arithmetic spec differ > on what constitutes engineering notation, there's a bug in the Python > decimal library, or you're hitting some obscure part of the spec's > definition. I don't have the e

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Chris Rebert
On Sun, Apr 25, 2010 at 9:42 PM, Keith wrote: > On Apr 26, 12:02 am, Chris Rebert wrote: >> On Sun, Apr 25, 2010 at 8:36 PM, Keith wrote: >> > I am considering writing a PEP for the inclusion of an engineering >> > format specifier, and would appreciate input from others. >  snip >> Relevant rel

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Keith
On Apr 26, 12:29 am, Steven D'Aprano wrote: > On Sun, 25 Apr 2010 20:36:22 -0700, Keith wrote: >>no one talks about 4.7e-5F, as they would rather see 47e-6 >>(micro). Instead of 2.2e-2, engineers need to see 22.0e-3 (milli). >I'd be cautious about making claims about "no one" Good point, and I

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Keith
On Apr 26, 12:02 am, Chris Rebert wrote: > On Sun, Apr 25, 2010 at 8:36 PM, Keith wrote: > > I am considering writing a PEP for the inclusion of an engineering > > format specifier, and would appreciate input from others. snip > Relevant related information: > The Decimal datatype supports engin

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Steven D'Aprano
On Sun, 25 Apr 2010 20:36:22 -0700, Keith wrote: > I am considering writing a PEP for the inclusion of an engineering > format specifier, and would appreciate input from others. [...] > For instance, no one talks about 4.7e-5F, as they would rather see 47e-6 > (micro). Instead of 2.2e-2, engineer

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Chris Rebert
On Sun, Apr 25, 2010 at 8:36 PM, Keith wrote: > I am considering writing a PEP for the inclusion of an engineering > format specifier, and would appreciate input from others. > > Background (for those who don't already know about engineering > notation): > > Engineering notation (EN) is type of fl

Engineering numerical format PEP discussion

2010-04-25 Thread Keith
I am considering writing a PEP for the inclusion of an engineering format specifier, and would appreciate input from others. Background (for those who don't already know about engineering notation): Engineering notation (EN) is type of floating point representation. The idea with EN is that the p