[Python-ideas] numerical type combining integer and float/decimal properties [Was: Re: Python Numbers as Human Concept Decimal System]

Guido van Rossum guido at python.org
Wed Mar 12 17:13:29 CET 2014


On Wed, Mar 12, 2014 at 8:48 AM, Wolfgang Maier <
wolfgang.maier at biologie.uni-freiburg.de> wrote:

> Guido van Rossum <guido at ...> writes:
> > This representation makes more sense, it is fixed point. But you can just
> use a single integer and keep track of where the point should be.
>
> Right, the main reason why I haven't tried that is that I started out with
> an int for representing the integral part and a Decimal for the rest, so
> from the beginning I always had two separate objects in the code.
> On the other hand, I assume that a single int might also slow down the
> trimming of the fractional part, which is necessary to keep its precision
> fixed ?
>

You can't be sure without timing it, but my expectation is that unless the
number of digits is really large (like in the 1000s or more) the fewer
number of operations will always be quicker.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140312/cfbd5403/attachment.html>


More information about the Python-ideas mailing list