Q:

Why this implementations have different results?

Hi i need to generate some hash / checksum from same text in c# and ts/js
i found some solution here on stackoverflow but have some issue 
so my js
private getStableHash(s, hashlength) {
let hash = 0;
const bytes = this.string2Bin(s); 
for (let i = 0; i < bytes.length; i++) {
    hash += bytes[i];
    hash += (hash << 10);
    hash ^= (hash >> 6);
}
// final avalanche
hash += (hash << 3);
console.log(hash);
hash ^= (hash >> 11);
console.log(hash);
hash += (hash << 10);
console.log(hash);
return Math.round(hash % hashlength);
}

 private string2Bin(str) {
 const result = [];
 for (let i = 0; i < str.length; i++) {
  result.push(str.charCodeAt(i));
 }
 return result;
 }

and c#
 private int GetStableHash(string s, int hashlength)
    {
        int hash = 0;
        var bytes = System.Text.Encoding.ASCII.GetBytes(s);
        foreach (byte b in bytes)
        {
            hash += b;
            hash += (hash << 10);
            hash ^= (hash >> 6);
        }
        // final avalanche
        hash += (hash << 3);
        hash ^= (hash >> 11);
        hash += (hash << 10);

        return (int)(hash % hashlength);
    }

getStableHash('dbo.files.xxx.yyy.zzz/aaa/3',10000000)
returns 7414302 in both cases so it is FINE
but if i change this last line
  hash += (hash << 10);

to 
  hash += (hash << 15);

in both implementations
c#change in this line 474798750 to -1986274658 and returns -6274658 
and
js changein this line 474798750 to 2308692638 and returns 8692638
why is that ? what im missing here?
regards !

A:

int in C# is a singed 32bit integer. If you do bitshifting that sets the first bit to 1, the number will get negative. 
numbers in JS are 64bit floating point numbers, with 52bit integer precision. Bitwise operators are however only done on a 32bit signed representation of the number.
Therefore the bitshifting << is the same in both, but the addition += only works on 32 bit in C#, but on 52bit in JS.

