In neither is lngResult initialized, so we'll presume the intent wast to start with 0.

The first one sums the entries in the array multiplied by 2 raised to decreasing multiples of seven.

The powers of two are 3*7, 2*7, 1*7, and 0*7, or 21, 14, 7, and 0.

This also has the effect of shifting the entries in the array left by 21, 14, 7, and 0 bits each.

So the final result is array(0)<<21 OR array(1)<<14 OR array(2)<<7 OR array(3).

Or, putting the entries in array into seven bit clumps. Given that your example has arr(3) requiring 8 bits, I'd be much happier if the powers of two were multiples of 8 instead of 7.

In any case, the second one has the effect of making a 32-bit item with the array entries stored left to right, 0 to 3, the result being a long whose value is:

65536*(256*arr(3) + arr(2)) + (256*arr(1)+arr(0) (recall that on Intel CPUs, bytes in integers are stored least significant first).

Note that can also be considered reversing the entries of the array and puting the result into 32 bits.

Given what the second one does, if the multiplier in the first one had been 8, it's result would have been putting the entries in the array into a 32-bit item in the same order as the second.

The first one sums the entries in the array multiplied by 2 raised to decreasing multiples of seven.

The powers of two are 3*7, 2*7, 1*7, and 0*7, or 21, 14, 7, and 0.

This also has the effect of shifting the entries in the array left by 21, 14, 7, and 0 bits each.

So the final result is array(0)<<21 OR array(1)<<14 OR array(2)<<7 OR array(3).

Or, putting the entries in array into seven bit clumps. Given that your example has arr(3) requiring 8 bits, I'd be much happier if the powers of two were multiples of 8 instead of 7.

In any case, the second one has the effect of making a 32-bit item with the array entries stored left to right, 0 to 3, the result being a long whose value is:

65536*(256*arr(3) + arr(2)) + (256*arr(1)+arr(0) (recall that on Intel CPUs, bytes in integers are stored least significant first).

Note that can also be considered reversing the entries of the array and puting the result into 32 bits.

Given what the second one does, if the multiplier in the first one had been 8, it's result would have been putting the entries in the array into a 32-bit item in the same order as the second.