- or download this
# Perl program to add two numbers using only bitwise operators
# See https://stackoverflow.com/questions/4068033/add-two-integers-usi
+ng-only-bitwise-operators
...
$sum0 == $sum2 or die "oops 2";
$sum1 == $sum2 or die "oops 3";
}
- or download this
0 + 1 = 1 (1 1)
1 + -1 = 0 (0 0)
...
123456789 + 1 = 123456790 (123456790 123456790)
2147483647 + 1 = 2147483648 (2147483648 2147483648)
-2147483648 + 1 = -2147483647 (-2147483647 -2147483647)
- or download this
// C++ Program to add two numbers without using arithmetic operator.
// bitadd.cpp
...
return 0;
}
- or download this
sizeof my int = 8
0 + 1 = 1 (1)
...
123456789 + 1 = 123456790 (123456790)
2147483647 + 1 = 2147483648 (2147483648)
-2147483648 + 1 = -2147483647 (-2147483647)