BCD List to HEX List

bryanjugglercryptographer at yahoo.com bryanjugglercryptographer at yahoo.com
Tue Aug 1 01:43:41 EDT 2006


John Machin wrote:
> bryanjugglercryptographer at yahoo.com wrote:
> > 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
>
> Yeah yeah yeah
> i.e. y = y * 10 + n
> he's been shown that already.
>
> Problem is that the OP needs an 8-decimal-digit (32-bits) answer, but
> steadfastly maintains that he doesn't "have access to" long (32-bit)
> arithmetic in his C compiler!!!

And he doesn't need one. He might need the algorithms for shift and
add.


-- 
--Bryan




More information about the Python-list mailing list