proposed language change to int/int==float (was: PEP0238 lament)

Toby Dickenson tdickenson at devmail.geminidataloggers.co.uk
Wed Jul 25 03:34:56 EDT 2001


Guido van Rossum <guido at python.org> wrote:

>"Bjorn Pettersen" <BPettersen at NAREX.com> writes:
>
>> I think perhaps an equally interesting example is something like:
>> 
>>   2L**128/2
>> 
>> which currently gives an exact result, but under the proposed new
>> semantics would give an approximation...
>
>Have you read the PEP?  The PEP only returns a float if the int result
>would yield a remainder.

That bit of the PEP didnt register on a first reading, and now I am
suprised at that rule.

As I understand it, this means long/long would sometimes give an exact
result and sometimes an approximation, depending on whether the
remainder is zero.

The problem isnt quite as simple as Bjorn was suggesting, but this is
definitely suprising:

>>> ((2L**1000)+0)/2
1071508607186267320948425.... <more digits snipped>

>>> ((2L**1000)+1)/2
1.07150860719e+301

>>> ((2L**2000)+0)/2
1148130695274254524232833.... <more digits snipped>

>>> ((2L**2000)+1)/2
inf



Toby Dickenson
tdickenson at geminidataloggers.com



More information about the Python-list mailing list