bit_manipulation.bitwise_addition_recursive

Calculates the sum of two non-negative integers using bitwise operators Wikipedia explanation: https://en.wikipedia.org/wiki/Binary_number

Functions

bitwise_addition_recursive(→ int)

Module Contents

bit_manipulation.bitwise_addition_recursive.bitwise_addition_recursive(number: int, other_number: int) int
>>> bitwise_addition_recursive(4, 5)
9
>>> bitwise_addition_recursive(8, 9)
17
>>> bitwise_addition_recursive(0, 4)
4
>>> bitwise_addition_recursive(4.5, 9)
Traceback (most recent call last):
    ...
TypeError: Both arguments MUST be integers!
>>> bitwise_addition_recursive('4', 9)
Traceback (most recent call last):
    ...
TypeError: Both arguments MUST be integers!
>>> bitwise_addition_recursive('4.5', 9)
Traceback (most recent call last):
    ...
TypeError: Both arguments MUST be integers!
>>> bitwise_addition_recursive(-1, 9)
Traceback (most recent call last):
    ...
ValueError: Both arguments MUST be non-negative!
>>> bitwise_addition_recursive(1, -9)
Traceback (most recent call last):
    ...
ValueError: Both arguments MUST be non-negative!