f(p) { residue = "" loop for 14 digits: { digit = substring('0123456789ABCDEF',(p & 0xF)+1,1) p = ((p & 0x8FFFFFFF) << 1) | (p >> 28) residue = concat(residue,digit) } return concat(residue,'__') } & is bitwise AND: 0&0=0 0&1=0 1&0=0 1&1=1 | is bitwise OR: 0&0=0 0&1=1 1&0=1 1&1=1 digit = substring('0123456789ABCDEF',(p & 0xF)+1,1) This line simply takes p mod 16 and assign the hex value to the residue, since & is bitwise AND and 0xF is 1111 in binary. So for example if p%16=11 then digit=B and so on. p = ((p & 0x8FFFFFFF) << 1) | (p >> 28) I'm pretty sure this was a type and meant as (p & 0xFFFFFFFF) not (p & 0x8FFFFFFF), otherwise the fake residues doesn't match this algorithm. (p & 0xFFFFFFFF) is bitwise AND between p in binary and 0xFFFFFFFF in binary. << 1 means shift result 1 bit to the left. (p >> 28) means shifting p 28 bits to the right. Then finally you take the bitwise OR between ((p & 0xFFFFFFFF) << 1) and (p >> 28) to get the next p in the iteration. Example: 43021553 69 0x1248125A492480__ 06-Sep-08 20:23 S60701 C5E5C0FB7 So lets call the initial p for p0. p0 is 43021553 in binary: p0 = 10100100000111010011110001 p0%16=1 so 1st char in residue is 1. p0: 10100100000111010011110001 0xFFFFFFFF: 11111111111111111111111111111111 (p0 & 0xFFFFFFFF): 10100100000111010011110001 ((p0 & 0xFFFFFFFF) << 1): 101001000001110100111100010 (p0 >> 28): 0000000000000000000000000000010100100000111010011110001 Now to find the new p, which I call p1 we do bitwise OR of the last 2 lines: So new p1 is: 101001000001110100111100010 p1%16=2 so 2nd char in residue is 2. 0xFFFFFFFF: 11111111111111111111111111111111 (p1 & 0xFFFFFFFF): 101001000001110100111100010 ((p1 & 0xFFFFFFFF) << 1): 1010010000011101001111000100 (p1 >> 28): 00000000000000000000000000000101001000001110100111100010 p2: 1010010000011101001111000100 p2%16=4 so 3rd char in residue is 4. 0xFFFFFFFF: 11111111111111111111111111111111 (p2 & 0xFFFFFFFF): 1010010000011101001111000100 ((p2 & 0xFFFFFFFF) << 1): 10100100000111010011110001000 (p2 >> 28): 000000000000000000000000000001010010000011101001111000100 p3: 10100100000111010011110001000 p3%16=8 so 4th char in residue is 8. 0xFFFFFFFF: 11111111111111111111111111111111 (p3 & 0xFFFFFFFF): 10100100000111010011110001000 ((p3 & 0xFFFFFFFF) << 1): 101001000001110100111100010000 (p3 >> 28): 0000000000000000000000000000010100100000111010011110001000 p4: 101001000001110100111100010001 p4%16=1 so 5th char in residue is 1. 0xFFFFFFFF: 11111111111111111111111111111111 (p4 & 0xFFFFFFFF): 101001000001110100111100010001 ((p4 & 0xFFFFFFFF) << 1): 1010010000011101001111000100010 (p4 >> 28): 00000000000000000000000000000101001000001110100111100010001 p5: 1010010000011101001111000100010 p5%16=2 so 6th char in residue is 2. 0xFFFFFFFF: 11111111111111111111111111111111 (p5 & 0xFFFFFFFF): 1010010000011101001111000100010 ((p5 & 0xFFFFFFFF) << 1): 10100100000111010011110001000100 (p5 >> 28): 000000000000000000000000000001010010000011101001111000100010 p6: 10100100000111010011110001000101 p6%16=5 so 7th char in residue is 5. 0xFFFFFFFF: 11111111111111111111111111111111 (p6 & 0xFFFFFFFF): 10100100000111010011110001000101 ((p6 & 0xFFFFFFFF) << 1): 101001000001110100111100010001010 (p6 >> 28): 0000000000000000000000000000010100100000111010011110001000101 p7: 101001000001110100111100010001010 p7%16=10 so 8th char in residue is A. 0xFFFFFFFF: 11111111111111111111111111111111 (p7 & 0xFFFFFFFF): 01001000001110100111100010001010 ((p7 & 0xFFFFFFFF) << 1): 010010000011101001111000100010100 (p7 >> 28): 0000000000000000000000000000101001000001110100111100010001010 p8: 10010000011101001111000100010100 p8%16=4 so 9th char in residue is 4. 0xFFFFFFFF: 11111111111111111111111111111111 (p8 & 0xFFFFFFFF): 10010000011101001111000100010100 ((p8 & 0xFFFFFFFF) << 1): 100100000111010011110001000101000 (p8 >> 28): 0000000000000000000000000000010010000011101001111000100010100 p9: 100100000111010011110001000101001 p9%16=9 so 10th char in residue is 9. 0xFFFFFFFF: 11111111111111111111111111111111 (p9 & 0xFFFFFFFF): 000100000111010011110001000101001 ((p9 & 0xFFFFFFFF) << 1): 001000001110100111100010001010010 (p9 >> 28): 0000000000000000000000000000100100000111010011110001000101001 p10: 1000001110100111100010001010010 p10%16=2 so 11th char in residue is 2. 0xFFFFFFFF: 11111111111111111111111111111111 (p10 & 0xFFFFFFFF): 1000001110100111100010001010010 ((p10 & 0xFFFFFFFF) << 1): 10000011101001111000100010100100 (p10 >> 28): 000000000000000000000000000001000001110100111100010001010010 p11: 10000011101001111000100010100100 p11%16=4 so 12th char in residue is 4. 0xFFFFFFFF: 11111111111111111111111111111111 (p11 & 0xFFFFFFFF): 10000011101001111000100010100100 ((p11 & 0xFFFFFFFF) << 1): 100000111010011110001000101001000 (p11 >> 28): 0000000000000000000000000000010000011101001111000100010100100 p12: 100000111010011110001000101001000 p12%16=8 so 13th char in residue is 8. 0xFFFFFFFF: 11111111111111111111111111111111 (p12 & 0xFFFFFFFF): 00000111010011110001000101001000 ((p12 & 0xFFFFFFFF) << 1): 000001110100111100010001010010000 (p12 >> 28): 0000000000000000000000000000100000111010011110001000101001000 p13: 1110100111100010001010010000 p13%16=0 so 14th char in residue is 0.