> It all looks pretty god but there is a couple of things I still don't > understand, 1) in Steve's solution (which seems equivalent to your > own), he does the masking, shifts by seven, and then sums the two > numbers while you, instead of summing, use a logical or. How can these > operations be equivalent? or are they? Is the logical or equivalent > to a concatenation?
No, but look at this: 111000 + 000111 = 111111 111000 | 000111 = 111111 Adding and or are yielding the same results as long as at least one of the bits combined is zero. By shifting the appropriate number of bits and thus clearing the lower ones and "anding" the second argument with 0x7f, this is ensured for the whole numbers. > > 2) why 7? why do we have shift 7 bits? is that so the 8th bit on byte > one is aligned with the first bit on the second byte? Because of the specification you gave - look at the Byte2 spec closely. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list