Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   unsigned long to unsigned char (http://www.velocityreviews.com/forums/t345569-unsigned-long-to-unsigned-char.html)

ashtonn@gmail.com 06-01-2005 05:43 PM

unsigned long to unsigned char
 
Hello,

Is it possible to convert unsigned long( 4 bytes) to unsigned char(1
byte), so that i could define a common array for both.

import array
temp = array('B', '\0' * 512)

for i in range( 2):
temp[0] = 0xFF
temp[1] = 0xFFFFFFFF

Thanks,
-Ashton


Diez B. Roggisch 06-01-2005 07:00 PM

Re: unsigned long to unsigned char
 
ashtonn@gmail.com wrote:
> Hello,
>
> Is it possible to convert unsigned long( 4 bytes) to unsigned char(1
> byte), so that i could define a common array for both.
>
> import array
> temp = array('B', '\0' * 512)
>
> for i in range( 2):
> temp[0] = 0xFF
> temp[1] = 0xFFFFFFFF


use module struct.

Diez


All times are GMT. The time now is 09:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.