[Python-Dev] Negative long literals (was Re: Does Python need a '>>>' operator?)

Michael Gilfix mgilfix@eecs.tufts.edu
Mon, 10 Jun 2002 09:24:19 -0400


On Mon, Jun 10 @ 09:12, Tim Peters wrote:
> [Michael Gilfix]
> >   I like the idea but I'm not sure that still solves the down casting
> > problem.
> 
> It's not even pretending to have something to do with downcasting.

  Er, I thought it was part of dealing with the int/long unification,
where it becomes more difficult to express signed numbers as well.
I think my phrasing was of. Should have been: Now if only we could
solve...

> > 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.

  Well, in today's python, if I want to operate on a 64-bit block (without
breaking it up into two ints), I could use a long to hold my value. Then
let's say I perform some operation and I know the result is a 32-bit value
and is signed. It's not easy to get it back into an int. I suppose with
unification, I could just do:

      if num & 0xA0000000:
          num = -num

  I just want a straight-forward way of expressing that it's signed.

                        -- Mike

-- 
Michael Gilfix
mgilfix@eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html