BCD List to HEX List

Philippe Martin pmartin at snakecard.com
Sun Jul 30 19:44:33 EDT 2006


John Machin wrote:

> 
> Philippe Martin wrote:
>> Philippe Martin wrote:
>>
>> > Hi,
>> >
>> > I'm looking for an algo that would convert a list such as:
>> >
>> > I'm using python to prototype the algo: this will move to C in an
>> > embedded system where an int has 16 bits - I do not wish to use any
>> > python library.
>> >
>> > l1 = [1,2,3,4,6,7,8] #represents the decimal number 12345678
>> > l2 = func (l1)
>> > # l2 = [0x1, 0x2, 0xD, 0x6, 0x8, 0x7] #represents 0x12D687
>> >
>> >
>> > Regards,
>> >
>> > Philippe
>>
>> Thanks to all,
>>
>> I decided to attack the problem another way and change the code in device
>> #2 so it can now take the output from device #1.
>>
>> As device #2 only needs to compare, add, and subtract the stuff .. it
>> makes my life much simpler.
>>
> 
> I'm confused.
> 1. Was the original device #1 or #2?
> 2. How many bits does the non-original device's C compiler support?
> 3. If the original device is device #1, please explain where *it*
> obtained an 8-digit decimal number expressed as 1 digit per byte (or
> int) ...


Well I don't want to bore you guys more than needed ;-) but:

Device #1 has an 8 bit processor - uses a C cross-compiler that does not
know anything above a 16 bit integer. I use this device to get information
from users "1234...".

Device #2 has an 8 bit processor - uses a subset of Java ... that does not
know anything above a 16 bit integer.


The information gathered in device number #1 must then be sent to device #2
(after being encrypted .... ) to be compared, subtracted or added.

The code I already have in device #2 makes the assumption that the
information received is an array of bytes of length N which represents an
actual value. ex: 0x67DF5 ==> [0x6, 0x7, 0xD, 0xF, 0x5] ... so it can
compare/add/subtract values ... and do its job.

As a python fan, I figured (back to my initial not very clear request), that
I could prototype the above without making any major assumption as to the
capabilities of the interpreter.


I still believe that to be true.

Regards,

Philippe

















More information about the Python-list mailing list