[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
Mon Mar 10 19:09:46 CET 2014


On Mon, Mar 10, 2014 at 11:03 AM, Wolfgang Maier <
wolfgang.maier at biologie.uni-freiburg.de> wrote:

> Guido van Rossum <guido at ...> writes:
>
> >
> >
> > I think what you're proposing here is variant of fixed-point numbers. The
> representation you seem to be looking for is an arbitrary-precision integer
> plus an exponent. A question for you: how would you treat results like 1/3?
> >
>
> No, I don't think this is what I'm proposing. I said digits left of the
> decimal point should behave like a Python integer, i.e., have arbitrary
> precision, but to the right of it things should look like a float or
> Decimal
> with fixed precision. So 1/3 would just look like float(1/3) for example.
>

I'm sorry, I still don't understand your proposal. Suppose I have two
numbers following that description and I divide them, and suppose the
result cannot be represented as a decimal or binary fraction. What is your
algorithm for deciding how many digits after the decimal point to keep? (Or
how many bits after the binary point -- are you proposing a binary or a
decimal representation?) Is the number of bits/digits to keep a constant,
or does it vary by how many digits/bits are to the left of the point? And
what about multiplications? Should they always produce an exact result or
should they truncate if the result requires more digits/bits behind the
point than a certain number? (If the latter, how is that limit determined?)

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


More information about the Python-ideas mailing list