![]() |
VOOZH | about |
This article will show you how to add two numbers without using Arithmetic operators in PHP. There are two methods to add two numbers, these are:
Table of Content
We will use Bitwise Operator to add two numbers. First, we check num2 is not equal to zero, then Calculate the carry using & operator, and then use XOR operator to get sum of numbers, At last, shift the carry to 1 left.
Sum : 12
In this section, we will use the above approach with Recursion to calculate the sum of two numbers.
Example:
Sum : 12