what about unsigned and signed 8 bits number, 16 bits, etc??

A. Lloyd Flanagan alloydflanagan at comcast.net
Tue Jun 15 20:40:13 CEST 2004


sarmin kho <sarmin_kho at yahoo.com> wrote in message news:<mailman.937.1087219380.6949.python-list at python.org>...
> Hi Pythoners,
>  
> When it is an integer number, what is the range of the integer number and 
>long integer number??
>  

The integer number is a C long, which is often but not always a 4-byte
value:
range:  -2147483648 -- 2147483647

> do we have typecasting of 8bits or 16bits signed and unsigned number in 
>python?

Typecasting is not necessary in Python due to the unique type system. 
I believe in every case you mentioned, Python will promote the number
to a simple (signed) int.
If you need to deal directly with C types or structures, there's a
module or two for doing that.

> the python script i m working on would need to typecast the number it reads 
> from a hardware. this number would then be typecasted according to its type 
> before further processing. the typecasting is in form of signed 8bits and 
> 16bits number. how do i do this in python??

Again, you may not have to worry about it, depending on your types. 
But you can say int(x) to make an integer from x, long(x) to make a
long integer, str(x) for string, and float(x) for float.

You should read section 3.2 of the Language Reference,
http://docs.python.org/ref/types.html.



More information about the Python-list mailing list