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

Facundo Batista facundobatista at gmail.com
Tue Jun 28 08:33:50 CEST 2005


On 6/27/05, Fredrik Johansson <fredrik.johansson at gmail.com> wrote:

> 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.

You mean something like this?

>>> from __future__ import new_float_behaviour
>>> 1.1
1.1
>>> import sys
>>> sys.float_context.binary = True
>>> 1.1
1.1000000000000001

I don't see why this couldn't be done. The default will be use decimal
fp, and you can switch to binary fp if you need silicon-speed (unless,
of course, you have decimal-on-silicon).

In decimal mode, the context will be a full one, in binary mode, it's
not mandatory to allow access to fpu flags, it could be just like now.

.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/


More information about the Python-Dev mailing list