src/IntMath.php
/**
     * Returns the sum of the arguments.
     *
     * The result is the low-order bits of the true mathematical result as
     * represented in a sufficiently wide two's-complement format. If overflow
     * occurs, then the sign of the result may not be the same as the sign of
     * the mathematical sum of the two values. Despite the overflow, no
     * exception is thrown in this case.
     *
     * @param integer $a The addend.
     * @param integer $b The addend.
     *
     * @return integer The sum.
     *
     * @throws InvalidArgumentException If one of the arguments is not an
     *                                  integer.
     */
Returns the sum of the arguments.
The result is the low-order bits of the true mathematical result as
represented in a sufficiently wide two's-complement format. If overflow
occurs, then the sign of the result may not be the same as the sign of
the mathematical sum of the two values. Despite the overflow, no
exception is thrown in this case.

@param integer $a The addend.
@param integer $b The addend.

@return integer The sum.

@throws InvalidArgumentException If one of the arguments is not an
integer.
Returns the sum of the arguments . The result is the low - order bits of the true mathematical result as represented in a sufficiently wide two ' s - complement format . If overflow occurs then the sign of the result may not be the same as the sign of the mathematical sum of the two values . Despite the overflow no exception is thrown in this case . @param integer $a The addend . @param integer $b The addend . @return integer The sum . @throws InvalidArgumentException If one of the arguments is not an integer .
public static function add($a, $b)
    {
        self::assertInteger($a);
        self::assertInteger($b);
        if (($b > 0) && ($a <= (\PHP_INT_MAX - $b))) {
            return $a + $b;
        }
        if (($b < 0) && ($a >= (\PHP_INT_MIN - $b))) {
            return $a + $b;
        }
        while ($b !== 0) {
            $carry = $a & $b;
            $a ^= $b;
            $b = $carry << 1;
        }
        return $a;
    }
public static function add ( $ a , $ b ) { self :: assertInteger ( $ a ) ; self :: assertInteger ( $ b ) ; if ( ( $ b > 0 ) && ( $ a <= ( \ PHP_INT_MAX - $ b ) ) ) { return $ a + $ b ; } if ( ( $ b < 0 ) && ( $ a >= ( \ PHP_INT_MIN - $ b ) ) ) { return $ a + $ b ; } while ( $ b !== 0 ) { $ carry = $ a & $ b ; $ a ^= $ b ; $ b = $ carry << 1 ; } return $ a ; }
Returns the sum of the arguments.
Returns the sum of the arguments .
// Carry now contains common set bits of the addends // Sum of bits of $x and $y, // where at least one of the bits is not set // Left-shift by one