public function mod($dividend, $divisor)
    {
        if ($divisor === 0) {
            return 0;
        }

        $modulus = $dividend % $divisor;
        if ($modulus < 0) {
            $modulus += $divisor;
        }

        return $modulus;
    }
public function mod($dividend, $divisor)
    {
        if ($divisor === 0) {
            return 0;
        }

        $modulus = $dividend % $divisor;
        if ($modulus < 0) {
            $modulus += $divisor;
        }

        return $modulus;
    }
public function mod ( $ dividend , $ divisor ) { if ( $ divisor === 0 ) { return 0 ; } $ modulus = $ dividend % $ divisor ; if ( $ modulus < 0 ) { $ modulus += $ divisor ; } return $ modulus ; }
The PHP modulus function returns a negative modulus for a negative dividend.
This algorithm requires a "traditional" modulus function where the modulus is
always positive.

@param int $dividend
@param int $divisor

@return int
The PHP modulus function returns a negative modulus for a negative dividend . This algorithm requires a traditional modulus function where the modulus is always positive .