A Python solution
For python the add function only works when \n ab>=0 , or\n  a < 0 and abs(a) > b > 0 (the negative number has a larger absolute value)\n  b < 0 and abs(b) > a 
For python the `add` function only works when \n* a*b>=0 , or\n*  a < 0 and abs(a) > b > 0 (the negative number has a larger absolute value)\n*  b < 0 and abs(b) > a > 0\n\nModify it accordingly (use `add(~n, 1)` to turn `n` into `-n`):  \n\n    def getSum(self, a, b):\n        def add(a, b): \n            if not a or not b:\n                return a or b\n            return add(a^b, (a&b) << 1)\n\n        if a*b < 0: # assume a < 0, b > 0\n            if a > 0:\n                return self.getSum(b, a)\n            if add(~a, 1) == b: # -a == b\n                return 0\n            if add(~a, 1) < b: # -a < b\n                return add(~add(add(~a, 1), add(~b, 1)),1) # -add(-a, -b)\n\n        return add(a, b) # a*b >= 0 or (-a) > b > 0 \n<br>\n\nIf we are allowed to use `-n`:\n<br>\n\n    def getSum(self, a, b):\n        def add(a, b): \n            if not a or not b:\n                return a or b\n            return add(a^b, (a&b) << 1)\n            \n        if a*b < 0: # assume a < 0, b > 0\n            if a > 0:\n                return self.getSum(b, a)\n            if -a == b:\n                return 0\n            if -a < b:\n                return -add(-a, -b)\n\n        return add(a, b)
['Python']