[Python-Dev] Negative long literals (was Re: Does Python need a
Mon, 10 Jun 2002 09:12:55 -0400
> I like the idea but I'm not sure that still solves the down casting
It's not even pretending to have something to do with downcasting.
> Say I do some bit ops on a long type and want to get it into an int
> size (for whatever reason and there are several), I need somehow to
> tell python that it is not an overflow when I'm int()ing the number.
Sorry, I don't know what you want it to do. You have to specify the
intended semantics first.
> Perhaps int could take a second hidden argument. Be
> able to do a:
> int(big_num, signed=1)
> which is pretty clear.
After int/long unification is complete, int() and long() will likely be the
same function. If you only want the last N bits, apply "&" to the long and
a bitmask with the N least-significant bits set.