Module of division
@param int|float|string|Decimal $op operand
@return Decimal
356829
public function mod($op)
  {
    $dst = clone $this;
    $op = $this->same($op, $this->prec)->truncate();
    if($op->eq(0)) throw new ArithmeticException(sprintf('Division by zero (%s)', json_encode($op)));
    $dst->value = $this->_fix($this->_mod($op));
    return $dst;
  }
1331549
function Multiplication(Selectable $operand1, Selectable $operand2, $alias = '')
    {
        return $this->CreateMultiplication($operand1, $operand2, $alias);
    }
82022
public static function convertToNumberIfFraction(&$operand)
    {
        if (preg_match('/^'.self::STRING_REGEXP_FRACTION.'$/i', $operand, $match)) {
            $sign = ($match[1] == '-') ? '-' : '+';
            $fractionFormula = '='.$sign.$match[2].$sign.$match[3];
            $operand = PHPExcel_Calculation::getInstance()->_calculateFormulaValue($fractionFormula);
            return true;
        }
        return false;
    }
1105165
public function divide($divisor, $roundingMode = self::ROUND_HALF_UP)
    {
        $this->assertOperand($divisor);
        $this->assertRoundingMode($roundingMode);

        if ($divisor == 0) {
            throw new InvalidArgumentException('Division by zero');
        }

        return new self(round($this->amount / $divisor, $this->currency->getPrecision(), $roundingMode), $this->currency);
    }
1279976
function mod($data, $op = null) {
		if (!($this->data instanceof Expr)) {
			$this->data = new Expr($this->name);
		}
		
		if ($data instanceof Expr) {
			$this->data->add($data);
		} elseif (!isset($op) && is_numeric($data)) {
			$this->data->add(new Expr("+ $data"));
		} else {
			$this->data->add(new Expr("%s %s", isset($op) ? $op : "||", $data));
		}
		
		return $this;
	}
275921
public function div(Decimal $b, int $scale = null): Decimal
    {
        self::paramsValidation($b, $scale);

        if ($b->isZero()) {
            throw new \DomainException("Division by zero is not allowed.");
        } elseif ($this->isZero()) {
            return DecimalConstants::Zero();
        } else {
            if (null !== $scale) {
                $divscale = $scale;
            } else {
                // $divscale is calculated in order to maintain a reasonable precision
                $this_abs = $this->abs();
                $b_abs    = $b->abs();

                $log10_result =
                    self::innerLog10($this_abs->value, $this_abs->scale, 1) -
                    self::innerLog10($b_abs->value, $b_abs->scale, 1);

                $divscale = (int)\max(
                    $this->scale + $b->scale,
                    \max(
                        self::countSignificativeDigits($this, $this_abs),
                        self::countSignificativeDigits($b, $b_abs)
                    ) - \max(\ceil($log10_result), 0),
                    \ceil(-$log10_result) + 1
                );
            }

            return self::fromString(
                \bcdiv($this->value, $b->value, $divscale+1), $divscale
            );
        }
    }
1199565
public function mod(Decimal $d, int $scale = null): Decimal
    {
        $div = $this->div($d, 1)->floor();
        return $this->sub($div->mul($d), $scale);
    }
265365
public function process()
    {
        $operands = $this->getOperands();

        if ($operands->containsNull() === true) {
            return null;
        }

        if ($operands->exclusivelySingle() === false) {
            $msg = "The Round operator only accepts operands with a single cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        if ($operands->exclusivelyNumeric() === false) {
            $msg = "The Round operator only accepts operands with baseType integer or float.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

        $operand = $operands[0];
        $mode = ($operand->getValue() >= 0) ? PHP_ROUND_HALF_UP : PHP_ROUND_HALF_DOWN;

        return new QtiInteger(intval(round($operand->getValue(), 0, $mode)));
    }
8694
protected function convertFlag(Op\FlagOp $op)
    {
        return $op->isEnabled()
            ? ProtoBuf\MapUpdate\FlagOp::ENABLE
            : ProtoBuf\MapUpdate\FlagOp::DISABLE;
    }
863325
public static function round($op1, $precision = 0)
    {
        if (self::$_bcmathDisabled) {
            $op1 = round($op1, $precision);
            if (strpos((string) $op1, 'E') === false) {
                return self::normalize(round($op1, $precision));
            }
        }

        if (strpos($op1, 'E') !== false) {
            $op1 = self::floatalize($op1);
        }

        $op1    = trim(self::normalize($op1));
        $length = strlen($op1);
        if (($decPos = strpos($op1, '.')) === false) {
            $op1 .= '.0';
            $decPos = $length;
            $length += 2;
        }
        if ($precision < 0 && abs($precision) > $decPos) {
            return '0';
        }

        $digitsBeforeDot = $length - ($decPos + 1);
        if ($precision >= ($length - ($decPos + 1))) {
            return $op1;
        }

        if ($precision === 0) {
            $triggerPos = 1;
            $roundPos   = -1;
        } elseif ($precision > 0) {
            $triggerPos = $precision + 1;
            $roundPos   = $precision;
        } else {
            $triggerPos = $precision;
            $roundPos   = $precision -1;
        }

        $triggerDigit = $op1[$triggerPos + $decPos];
        if ($precision < 0) {
            // zero fill digits to the left of the decimal place
            $op1 = substr($op1, 0, $decPos + $precision) . str_pad('', abs($precision), '0');
        }

        if ($triggerDigit >= '5') {
            if ($roundPos + $decPos == -1) {
                return str_pad('1', $decPos + 1, '0');
            }

            $roundUp = str_pad('', $length, '0');
            $roundUp[$decPos] = '.';
            $roundUp[$roundPos + $decPos] = '1';

            if ($op1 > 0) {
                if (self::$_bcmathDisabled) {
                    return Zend_Locale_Math_PhpMath::Add($op1, $roundUp, $precision);
                }
                return self::Add($op1, $roundUp, $precision);
            } else {
                if (self::$_bcmathDisabled) {
                    return Zend_Locale_Math_PhpMath::Sub($op1, $roundUp, $precision);
                }
                return self::Sub($op1, $roundUp, $precision);
            }
        } elseif ($precision >= 0) {
            return substr($op1, 0, $decPos + ($precision ? $precision + 1: 0));
        }

        return (string) $op1;
    }
60000
public static function StackCalculus ($operand_left, $operator, $operand_right) {
		$operand_left	*= 1.0;
		$operand_right	*= 1.0;
		switch ($operator) {
			case '+':
				return $operand_left + $operand_right;
			case '-':
				return $operand_left - $operand_right;
			case '*':
				return $operand_left * $operand_right;
			case '/':
				if ($operand_right == 0) {
					return false;
				}
				return $operand_left / $operand_right;
			case '%':
				return $operand_left % $operand_right;
		}
	}
917514
def mod(ctx, number, divisor):
    
    number = conversions.to_decimal(number, ctx)
    divisor = conversions.to_decimal(divisor, ctx)
    return number - divisor * _int(ctx, number / divisor)
209911
public static function Mod($op1, $op2)
    {
        $op1 = self::exponent($op1);
        $op2 = self::exponent($op2);
        return bcmod($op1, $op2);
    }
957012
public static function normaliseOperator($operator)
    {
        switch ($operator) {
            case 'add':
            case 'addition':
                $operator = '+';
                break;
            case 'sub':
            case 'subtract':
                $operator = '-';
                break;
            case 'mul':
            case 'multiply':
                $operator = '*';
                break;
            case 'div':
            case 'divide':
                $operator = '/';
                break;
            case 'mod':
            case 'modulus':
                $operator = '%';
                break;
            case 'comp':
            case 'compare':
                $operator = '=';
                break;
        }
        return $operator;
    }
597803
def div(a, b):
  
  def divide(a, b):
    """Division"""
    return a / b
  return op_with_scalar_cast(a, b, divide)
814663
protected function doOperation( Operator $op ) {
		if ( count( $this->operands ) < 2 ) {
			$op->error( 'missing operand' );
		}
		$right = array_pop( $this->operands );
		$left = array_pop( $this->operands );
		$result = $op->operate( $left, $right );
		$this->operands[] = $result;
	}
416883
public function additiveInverse(): Decimal
    {
        if ($this->isZero()) {
            return $this;
        } elseif ($this->isNegative()) {
            $value = \substr($this->value, 1);
        } else { // if ($this->isPositive()) {
            $value = '-' . $this->value;
        }

        return new static($value, $this->scale);
    }