range of int() type.
What is the range of a variable of type int() eg: i = int() print i.max() # 0x print i.min() # 0x is it a signed 16 bit or 32 bit or is it unsigned 16 or 32... I've noticed that it can be incremented into a new class of type long... -- http://mail.python.org/mailman/listinfo/python-list
Re: range of int() type.
KraftDiner wrote: What is the range of a variable of type int() eg: i = int() print i.max() # 0x print i.min() # 0x is it a signed 16 bit or 32 bit or is it unsigned 16 or 32... I've noticed that it can be incremented into a new class of type long... | import sys | sys.maxint 2147483647 From the sys module docs: maxint The largest positive integer supported by Python's regular integer type. This is at least 2**31-1. The largest negative integer is -maxint-1 -- the asymmetry results from the use of 2's complement binary arithmetic. Peace, ~Simon P.S. ints and longs are becoming unified soon. -- http://mail.python.org/mailman/listinfo/python-list
Re: range of int() type.
Simon Forman wrote: KraftDiner wrote: What is the range of a variable of type int() eg: i = int() print i.max() # 0x print i.min() # 0x is it a signed 16 bit or 32 bit or is it unsigned 16 or 32... I've noticed that it can be incremented into a new class of type long... | import sys | sys.maxint 2147483647 So what type / class should one use to represent a 16 bit integers (signed or unsigned)? From the sys module docs: maxint The largest positive integer supported by Python's regular integer type. This is at least 2**31-1. The largest negative integer is -maxint-1 -- the asymmetry results from the use of 2's complement binary arithmetic. Peace, ~Simon P.S. ints and longs are becoming unified soon. -- http://mail.python.org/mailman/listinfo/python-list
Re: range of int() type.
At Wednesday 23/8/2006 18:53, KraftDiner wrote: | import sys | sys.maxint 2147483647 So what type / class should one use to represent a 16 bit integers (signed or unsigned)? Plain int. If you need the overflow at 32K/64K, try: x 0x Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: range of int() type.
KraftDiner [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] So what type / class should one use to represent a 16 bit integers (signed or unsigned)? For most purposes, Python just has integers, with 'small' ones (depending on the machine) handled more efficiently. For special purposes, you may want to use the array or struct modules. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: range of int() type.
Terry Reedy wrote: KraftDiner [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] So what type / class should one use to represent a 16 bit integers (signed or unsigned)? For most purposes, Python just has integers, with 'small' ones (depending on the machine) handled more efficiently. For special purposes, you may want to use the array or struct modules. tjr Ok so the bottom line is.. if I have two arrays... a = array.array('L') a.append(65536L) b = array.array('H') b.append(a[0]) I will get the error: File stdin, line 1, in ? OverflowError: unsigned short is greater than maximum This is obvious... but how do I crop off the high order bits if necessary? a[0]0x ? -- http://mail.python.org/mailman/listinfo/python-list
Re: range of int() type.
23 Aug 2006 17:28:48 -0700, KraftDiner [EMAIL PROTECTED]: This is obvious... but how do I crop off the high order bits if necessary? a[0]0x ? min(a[0], 0x) ? -- Felipe. -- http://mail.python.org/mailman/listinfo/python-list