<br> Question:<br><br> I have a C program that has a line of code like this:<br><br> mx = (z>>5 ^ y<<2) + (y>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z);<br><br> All the variables are unsigned long<br>
<br> How do I code this in Erlang?<br><br> First thoughts:<br> <br> transcribe X >> N as trim(X bsl N)<br> X << N as trim(X bsr N)<br> X + Y as trim(X + Y)<br> X ^ Y as X bxor Y
<br> where trim(X) = X band 16#ffffffff<br><br> Is this correct? - The result must be bit identical to the C code,<br> how many of the trims can I eliminate?<br><br> A nieve translation of (y>>3 ^ z<<4)
<br><br> is trim(Y bsr 3) bxor trim(Z bsl 4)<br><br> identical to trim((Y bsr 3) bxor (Z bsl 4)) ????<br><br>/Joe<br><br>(And for ten extra brownie points: identify the algorithm :-)<br><br>