Data Structures, Algorithms, & Applications in Java
Chapter 11, Exercise 11

Each char, in Java, is 16 bits. Therefore, the two left shifts and adds of Program 11.13 essentially concatenate the binary representations of the rightmost three characters of s. Further, since a long is 64 bits and the concatenation of the three characters affects only the least significant 3 * 16 = 48 bits of answer, no bits are lost during the left shifts and there is no overflow during the adds. Therefore, at the end, the least significant 48 bits of answer faithfully represent the concatenation of the 16 bits in each of the three characters of the input string s. Consequently, different three-character strings u and v are converted into different numbers.