This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients mark.dickinson, rhettinger, steven.daprano
Date 2009-01-02.11:48:36
SpamBayes Score 4.425599e-07
Marked as misclassified No
Message-id <1230896917.76.0.887409781686.issue4796@psf.upfronthosting.co.za>
In-reply-to
Content
One also has to worry about the exponent of the converted result:  e.g., 
should Decimal.from_float(10.0) produce Decimal('1E1') or Decimal('10')?
The latter looks nicer, to me.

IEEE 754 isn't much help here:  as far as I can tell it says nothing about 
binary <-> decimal conversions.

I see two reasonable strategies:  (1) always use the largest exponent 
possible (so we'd get Decimal('1E1') above), or (2) when the quantity 
converted is an exact integer, use an exponent of zero; otherwise fall 
back to (1).

Option (2) is pretty much what the recipe in the docs does already, I 
think:  it computes a quotient of two Decimals, each having exponent zero, 
so the preferred exponent of the result is also zero.
History
Date User Action Args
2009-01-02 11:48:37mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, steven.daprano
2009-01-02 11:48:37mark.dickinsonsetmessageid: <1230896917.76.0.887409781686.issue4796@psf.upfronthosting.co.za>
2009-01-02 11:48:37mark.dickinsonlinkissue4796 messages
2009-01-02 11:48:36mark.dickinsoncreate