Subtracts a number from another number.

@param int|float $num1 The left operand.
@param int|float $num2 The right operand.

@return int|float The result of the operation.
@throws \InvalidArgumentException
422418
public static function sub($num1, $num2)
    {
        if (!static::is($num1) || !static::is($num2)) {
            throw new \InvalidArgumentException("The \$num1 and \$num2 parameters must be numeric.");
        }

        return ($num1 - $num2);
    }
846072
private function imbReverseUs($num)
	{
		$rev = 0;
		for ($i = 0; $i < 16; ++$i) {
			$rev <<= 1;
			$rev |= ($num & 1);
			$num >>= 1;
		}
		return $rev;
	}
65107
public static function distance2(Vector $vector1, Vector $vector2) : float {
        $value = 0;
        $count = count($vector1);
        for ($i = 0;$i<$count;$i++) {
            $value += ($vector1[$i] - $vector2[$i]) * ($vector1[$i] - $vector2[$i]);
        }
        return $value;
    }
939428
public function D2B($num)
    {
        $this->preOpMethodParamsCheck(array($num));

        /* Make sure that we're dealing with a decimal number. */
        $num = $this->decodeHex($num);

        try {

            $bin = '';

            while ($this->math->comp($num, '0') > 0) {
                switch ($this->math->mod($num, '2')) {
                    case '1':
                        $bin .= '1';
                        break;
                    default:
                        $bin .= '0';
                        break;
                }

                $num = $this->math->div($num, '2');
            }

            return $bin;

        } catch (\Exception $e) {
            throw $e;
        }
    }
679998
public function subtract($b)
    {
        switch (true) {
            case $b instanceof Matrix:
                $c = $this->subtractMatrix($b);
                break;

            case $b instanceof ColumnVector:
                $c = $this->subtractColumnVector($b);
                break;
                
            case $b instanceof Vector:
                $c = $this->subtractVector($b);
                break;

            case is_int($b) or is_float($b):
                $c = $this->subtractScalar($b);
                break;

            default:
                throw new InvalidArgumentException('Cannot subtract a '
                    . gettype($b) . ' from a matrix.');
        }

        return $c;
    }
984029
public function subtract($arg1) : \Object\Value\Math {
		\Math::subtract2($this->result, $arg1, $this->scale);
		return $this;
	}
1330212
public static function add($float1, $float2)
    {
        if (!static::is($float1) || !static::is($float2)) {
            throw new \InvalidArgumentException("The \$float1 and \$float2 parameters must be of type float.");
        }

        return ($float1 + $float2);
    }
1048798
public static function subtract(\CArray $a, \CArray $b): \CArray
    {
        return parent::subtract($a, $b);
    }
1050693
public static function difference(int $stamp1, int $stamp2 = null): int
    {
        if (!is_int($stamp2)) {
            $stamp2 = time();
        }

        return $stamp2 > $stamp1 ? $stamp2 - $stamp1 : $stamp1 - $stamp2;
    }
1357582
public function subtract($left, $right) {
        if (empty($left)) {
            return $right;
        } elseif (empty($right)) {
            return $left;
        } elseif ($right[0] == '-') {
            return $this->add($left, substr($right, 1));
        } elseif ($left[0] == '-') {
            return '-' . $this->add(ltrim($left, '-'), $right);
        }
        $left    = $this->normalize($left);
        $right   = $this->normalize($right);
        $results = $this->subtractBinary($left, $right);
        $result  = BaseConverter::convertFromBinary($results[1], '0123456789');
        return $results[0] . $result;
    }
1157563
@Override
  public Double subtract12(Long arg1, Double arg2) {
    if (arg1 == null || arg2 == null) {
      return Double.NaN;
    } else {
      return arg1.doubleValue() - arg2;
    }
  }
409499
public function subtract($amount, $subtrahend)
    {
        return (string) Number::fromString(bcsub($amount, $subtrahend, $this->scale));
    }
1243809
public function invertm($num, $mod)
    {
        $num = $this->input($num);
        $mod = $this->input($mod);

        $x = '1';
        $y = '0';
        $num1 = $mod;

        do {
            $tmp = bcmod($num, $num1);

            $q = bcdiv($num, $num1);

            $num = $num1;

            $num1 = $tmp;

            $tmp = bcsub($x, bcmul($y, $q));

            $x = $y;

            $y = $tmp;

        } while (bccomp($num1, '0'));

        if (bccomp($x, '0') < 0) {
            $x = bcadd($x, $mod);
        }

        if (substr($num, 0, 1) === '-') {
            $x = bcsub($mod, $x);
        }

        return $x;
    }
542633
public static function Sub( $tm1, $tm2 )
	{
		try
		{
			if ( ! $tm1 instanceof TimeValue )
				throw new \InvalidArgumentException("$tm1");

			if ( ! $tm2 instanceof TimeValue )
				throw new \InvalidArgumentException("$tm2");

			$seconds1 = new DecimalValue( $tm1->Value->getTimestamp() );
			$seconds1->Add( $tm1->Value->microseconds );

			$seconds2 = new DecimalValue( $tm2->Value->getTimestamp() );
			$seconds2->Add( $tm2->Value->microseconds );

			$newSeconds = $seconds1->Sub( $seconds2 );
			$sign = $newSeconds->getIsNegative();

			$newSeconds = $newSeconds->getAbs();
			$days = $newSeconds->Div( 86400 )->getIntegerPart();
			$time = $newSeconds->Mod( 86400 );
			$hours = $time->Div( 3600 )->getIntegerPart();
			$time = $time->Sub( $hours * 3600 );
			$minutes = $time->Div( 60 )->getIntegerPart();
			$time = $time->Sub( $minutes * 60 );
			$seconds = $time->getIntegerPart();
			$micro = $time->getDecimalPart();

			$interval = new \DateInterval( sprintf( "P%02sDT%02sH%02sM%02sS", $days, $hours, $minutes, $seconds ) );
			$interval->hasValue = ! $newSeconds->getIsZero();
			$interval->invert = $sign;
			$interval->microseconds = $micro;

			return new DayTimeDurationValue( $interval );

			$diff = $tm2->Value->diff( $tm1->Value );
			return new DayTimeDurationValue( $diff );
		}
		catch( \OverflowException $ex )
		{
			throw XPath2Exception::withErrorCode( "FODT0001", Resources::FODT0001 );
		}
	}
230677
private function _convert_number(&$num)
    {
        if (!empty($this->_params['only_integer']))
            $num = (int)$num;
        else
            $num = (float)$num;
    }
1267923
public static double addAmounts(final double num1, final double num2) {
		final BigDecimal b1 = new BigDecimal(num1);
		final BigDecimal b2 = new BigDecimal(num2);
		BigDecimal b3 = b1.add(b2);
		b3 = b3.setScale(3, BigDecimal.ROUND_HALF_UP);
		final double result = b3.doubleValue();
		return result;
	}
127860
public static function subtractMillenium($ts = null, $num = 1)
	{
		return sfTime::subtract($ts, $num, sfTime::MILLENIUM);
	}