int hash(long key, int numBits) { int hashValue = ((key%19937)*(key%19937))%19937; return getAddress(hashValue,numBits); } int getAddress(int num, int numBits) { short int bit; short add = 0; int x; for (int i=0; i<=numBits-1; i++) { x = num>>i; bit = x%2; // Shift all the bits in "add" left by 1 position. add = add << 1; // Add the new bit to the "add" add += bit; } return add; }