https://github.com/seigtm/bitwiseaddition
Addition of two integers using only bitwise operators (C++).
https://github.com/seigtm/bitwiseaddition
addition bitwise bitwise-algorithms bitwise-arithmetic bitwise-operation bitwise-operations bitwise-operators bitwise-shifting bitwise-xor cpp cpp-examples cpp-templates sum
Last synced: 6 months ago
JSON representation
Addition of two integers using only bitwise operators (C++).
- Host: GitHub
- URL: https://github.com/seigtm/bitwiseaddition
- Owner: seigtm
- Archived: true
- Created: 2021-05-22T19:24:22.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-28T14:33:45.000Z (almost 4 years ago)
- Last Synced: 2025-02-23T03:46:53.612Z (8 months ago)
- Topics: addition, bitwise, bitwise-algorithms, bitwise-arithmetic, bitwise-operation, bitwise-operations, bitwise-operators, bitwise-shifting, bitwise-xor, cpp, cpp-examples, cpp-templates, sum
- Language: C++
- Homepage:
- Size: 4.88 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BitwiseAddition
Addition of two integers using only bitwise operators (C++).
```cpp
/**
Bitwise sum function for two integers.
@param first an integer argument, first summand
@param second an integer argument, second summand
@return The sum of a and b (integer)
*/
int bitwise_sum(int first = 0, int second = 0);
```## Usage example
```cpp
std::cout << bitwise_sum(3, 5) // Output: 8.
<< bitwise_sum(0, 0) // Output: 0.
<< bitwise_sum(5000, 3000) // Output: 8000.
<< bitwise_sum(171, 13) // Output: 184.
<< bitwise_sum(788, 131); // Output: 919.
```