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

Toby Dickenson tdickenson at
Wed Jul 25 09:34:56 CEST 2001

Guido van Rossum <guido at> wrote:

>"Bjorn Pettersen" <BPettersen at> 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

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

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

Toby Dickenson
tdickenson at

More information about the Python-list mailing list