code: public static function unsignedMod( $a, $b ) {
  		if ( $a & 0x80000000 ) {
  			$m = ( $a & 0x7fffffff ) % $b + 2 * ( 0x40000000 % $b );
  
  			return $m % $b;
  		} else {
  			return $a % $b;
  		}
  	}
docs: Take a modulo of a signed integer as if it were an unsigned integer.
  $b must be less than 0x40000000 and greater than 0
  
  @param int $a
  @param int $b
  
  @return int