[Python-Dev] Decimal floats as default (was: discussion aboutPEP239 and 240)

Fredrik Johansson fredrik.johansson at gmail.com
Mon Jun 27 20:55:29 CEST 2005


On 6/27/05, Michael Chermside <mcherm at mcherm.com> wrote:
> Fredrik Johansson writes:
> > In either case, compatibility can be ensured by allowing both n-digit
> > decimal and hardware binary precision for floats, settable via a float
> > context.
> 
> Perhaps you can show me a design (or working code) that proves me
> wrong, but I don't believe that such a design could be made compatible
> with the existing Decimal module... certainly while continuing to
> maintain compatibility with the Cowlinshaw specification.

Are you thinking of any particular problem?

> > There is the alternative of providing decimal literals by using
> > separate decimal and binary float base types
> 
> If, by this, you mean adding a "binary float context" modeled after
> the Decimal float context and providing access to the underlying FP
> flags and traps and generally enhancing the use of binary FP, then
> I think it's a great idea.

The context (as I envision it) would not be just a "binary float
context", but a universal float context that lets you choose between
binary and decimal precision at run time.

A context for Python's current float type would be a nice idea by
itself, though.

> It's probably impossible to write in a
> cross-platform manner (because C supplies support for binary FP but
> does not offer access to the flags and traps), but this is one of those
> few cases where it's worth using platform-and-compiler specific code.

I agree.

--Fredrik


More information about the Python-Dev mailing list