Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Philippe Martin wrote: > >> Marc 'BlackJack' Rintsch wrote: >> >>> And now please describe you problem a little better. ;-) >> >> I'll try. >> >> first of all python is not going to be used for my purpose (sigh) >> >> I have device A which holds a binary coded decimal array [N1,N2,....Nn] >> where the array represents a decimal number. >> >> In C: unsigned char dec[] = {1,2,3,4,5,6,7,8}; >> >> I need that array converted for device B into an array where each element >> represents the actual byte value. >> >> In C: the result would be unsigned char hex[] = >> {0x1,0x2,0xD,0x6,0x8,0x7}; >> >> I guess any pocket calculator goes through that process for dec/hex >> conversion. >> >> Hope that's clearer. > > Not really. Maybe I'm missing something obvious but I don't see the link > between your `dec` and `hex` values. 12345678 converted to hex is > bc614e. Do you need such a conversion? And should the result really be > one nibble (4 bit)/hex digit per array entry!? > > Ciao, > Marc 'BlackJack' Rintsch
My apologies, I clearly made a mistake with my calculator, yes the resulting array I would need is [0xb,0xc,0x6,0x1,0x4,0xe] Regards, Philippe -- http://mail.python.org/mailman/listinfo/python-list