4-byte string to integer

Fredrik Lundh effbot at telia.com
Wed Oct 4 14:06:37 EDT 2000


Alan Gauld wrote:
> Now assuming the bytes are integers making up the 
> digits you can just multiply and add succesive digits
> by successive powers of 10.
> 
> Thus for 1,2,3,4:
> 
> digits = (1,2,3,4)
> 
> m,n = 1,0
> for i in (1,2,3,4):
>    n = n + i*m
>    m = 10 * m

assuming 3.3-bit bytes, right?

</F>




More information about the Python-list mailing list