469,916 Members | 2,562 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,916 developers. It's quick & easy.

How to convert

Lad
How can I covert in Python a variable of a long type to variable of
Integer type?
Thank you for reply
L.

Mar 18 '06 #1
4 1333
>>> 10/3.0
3.3333333333333335
int(10/3.0)

3

Mar 18 '06 #2
Em Sáb, 2006-03-18 *s 05:12 -0800, Lad escreveu:
How can I covert in Python a variable of a long type to variable of
Integer type?


You can do "int(variable)", but it can't be always done (for example,
when variable > MAX_INT):
a=10L
a 10L int(a) 10 a=100000000000000000000000000000000000000000000000 0000000000000000L
a 10000000000000000000000000000000000000000000000000 00000000000000L int(a)

10000000000000000000000000000000000000000000000000 00000000000000L
Mar 18 '06 #3
Em Sáb, 2006-03-18 *s 10:38 -0300, Felipe Almeida Lessa escreveu:
Em Sáb, 2006-03-18 *s 05:12 -0800, Lad escreveu:
How can I covert in Python a variable of a long type to variable of
Integer type?


You can do "int(variable)", but it can't be always done (for example,
when variable > MAX_INT):


A more concrete example:
int(2**31) 2147483648L int(2**31-1) 2147483647 int(-2**31) -2147483648 int(-2**31-1)

-2147483649L
Mar 18 '06 #4
JuHui wrote:
10/3.0
3.3333333333333335

The above value is a float, not a long ...
int(10/3.0)
3
int(1l) 1 100000000000000000000 100000000000000000000L 100000000000000000000/1000000000000000000 100L int(100000000000000000000/1000000000000000000) 100


regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

Mar 18 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Lauren Quantrell | last post: by
1 post views Thread by Logan X via .NET 247 | last post: by
3 posts views Thread by Convert TextBox.Text to Int32 Problem | last post: by
7 posts views Thread by patang | last post: by
4 posts views Thread by Edwin Knoppert | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.