sub ModifiedMakeHashString($) { my $string = shift; my $hash = 0; for my $c (map {ord} split //,$string) { my $six_shift = ($hash & 0x03ffffff) << 6; my $sixteen_shift = ($hash & 0x0000ffff) << 16; my $inverse = ~($hash-1) & 0xffffffff; $hash = floored_addition( floored_addition($c, $six_shift), floored_addition($sixteen_shift, $inverse)); #printf "c = %09x, 6s = %09x, 16s = %09x, inv = %09x, hash = %09x\n", # $c, $six_shift, $sixteen_shift, $inverse, $hash; #printf "c = %d, hash = %d\n", $c, $hash; } return $hash; } sub floored_addition { my ($x,$y) = @_; for my $i (reverse (0 .. 31)) { my $check_mask = 1 << $i; if ($check_mask & $x & $y) { my $op_mask = ~(2**$i-1) & 0xffffffff; $x ^= $op_mask&$x; $y ^= $op_mask&$y; last; } last if $check_mask & ~$x & ~$y; } return $x + $y; }