BCD List to HEX List

bryanjugglercryptographer at yahoo.com bryanjugglercryptographer at yahoo.com
Mon Jul 31 12:06:38 EDT 2006


Philippe Martin wrote:
> Yes, I came here for the "algorithm" question, not the code result.

To turn BCD x to binary integer y,

  set y to zero
  for each nibble n of x:
    y = (((y shifted left 2) + y) shifted left 1) + n

Do you need instruction on extracting nibbles, and shifting and
adding integers?

A problem this small and simple does not call for a prototype.


-- 
--Bryan




More information about the Python-list mailing list