printing longs

G

garyp

Python 2.3.4 (#1, Oct 26 2004, 16:42:40)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2

How do I get python to print the usual answer: 8000000, not -80000000

Thanks,
Gary
 
J

John Machin

Python 2.3.4 (#1, Oct 26 2004, 16:42:40)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2

<stdin>:1: FutureWarning: hex/oct constants > sys.maxint will return
positive values in Python 2.4 and up

As your subject says, you are working with longs, so don't mix in an
int (0x8000000, which is negative in Python 2.3 and earlier) -- use
0x8000000L instead.
-80000000

"%x" % x
is enough.
How do I get python to print the usual answer: 8000000, not -80000000

"usual" in what context?

Cheers,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top