Engineering numerical format PEP discussion

Chris Rebert clp2 at rebertia.com
Mon Apr 26 01:39:43 EDT 2010


On Sun, Apr 25, 2010 at 10:25 PM, Xavier Ho <contact at xavierho.com> wrote:
> On Mon, Apr 26, 2010 at 3:19 PM, Chris Rebert <clp2 at rebertia.com> 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 expertise to know which is the case.
>>
>> The spec: http://speleotrove.com/decimal/decarith.pdf
>> (to-engineering-string is on page 20 if you're interested)
>>
> I just gave Page 20 a quick read, and it says:
>
>> if the number is non-zero, the converted exponent is adjusted to be a
>> multiple of three (engineering notation) by positioning the decimal point
>> with one, two, or three characters preceding it (that is, the part before
>> the decimal point will range from 1 through 999);
>
> Obviously that would make  '1234567' not an Engineering notation?

Well, I saw that too, but note how it's prefixed by (emphasis mine):

"The conversion **exactly follows the rules for conversion to
scientific numeric string** except in the case of finite numbers
**where exponential notation is used.**"

The description of to-scientific-string explains exactly when it uses
exponential notation, but it gets slightly technical and I'm not
interested enough, nor do I have the time at the moment, to read the
entire spec.

Cheers,
Chris
--
I hate RQAB-s
http://blog.rebertia.com



More information about the Python-list mailing list