unsigned long to unsigned char

Discussion in 'Python' started by ashtonn@gmail.com, Jun 1, 2005.

  1. Guest

    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
     
    , Jun 1, 2005
    #1
    1. Advertisements

  2. 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
     
    Diez B. Roggisch, Jun 1, 2005
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    965
    Eric Sosman
    Jul 8, 2003
  2. Steffen Fiksdal

    void*, char*, unsigned char*, signed char*

    Steffen Fiksdal, May 8, 2005, in forum: C Programming
    Replies:
    1
    Views:
    847
    Jack Klein
    May 9, 2005
  3. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,569
    Peter Shaggy Haywood
    Sep 20, 2005
  4. lovecreatesbeauty
    Replies:
    1
    Views:
    1,421
    Ian Collins
    May 9, 2006
  5. Ioannis Vranos
    Replies:
    11
    Views:
    1,066
    Ioannis Vranos
    Mar 28, 2008
  6. Ioannis Vranos

    Padding bits and char, unsigned char, signed char

    Ioannis Vranos, Mar 28, 2008, in forum: C Programming
    Replies:
    6
    Views:
    827
    Ben Bacarisse
    Mar 29, 2008
  7. Alex Vinokur
    Replies:
    9
    Views:
    1,097
    James Kanze
    Oct 13, 2008
  8. pozz
    Replies:
    12
    Views:
    1,053
    Tim Rentsch
    Mar 20, 2011
Loading...