BCD List to HEX List

John Machin sjmachin at lexicon.net
Tue Aug 1 18:49:19 EDT 2006


bryanjugglercryptographer at yahoo.com wrote:

>My version assumes three subroutines: extracting
> nibbles, shifting, and adding, Those are pretty simple, so I asked
> if he needed them rather than presenting them.
> Assuming we have
> them, the algorithm is three lines long.

Perhaps you could enlighten us by publishing (a) the spec for each of
the get_nibble(s), shift, and add subroutines (b) the three-line
algorithm (c) what the algorithm is intended to achieve ...

>
> He took a while to state the problem, but was clear from the start
> that he had lists of digits rather than an integer datatype.

Yes, input was a list [prototyping a byte array] of decimal digits. The
OUTPUT was also a list of something. A few messages later, it became
clear that the output desired was a list of hexadecimal digits. Until
he revealed that the input was up to 24 decimal digits,  I was pursuing
the notion that a solution involving converting decimal to binary (in a
32-bit long) then to hexadecimal was the way to go.

What is apparently needed is an algorithm for converting a "large"
number from a representation of one base-10 digit per storage unit to
one of a base-16  digit per storage unit,  when the size of the number
exceeds the size (8, 16, 32, etc bits) of the "registers" available. Is
that what you have?

Cheers,
John




More information about the Python-list mailing list