From 9ea779cc136e7a41b01bf0ede045ab7cdcaff275 Mon Sep 17 00:00:00 2001 From: KeyboardZ7 Date: Sat, 1 Aug 2026 03:07:54 +0300 Subject: [PATCH] Update add_bitwise_operator.py Added a value error check to avoid negatives and inaccurate outputs. --- algorithms/bit_manipulation/add_bitwise_operator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/algorithms/bit_manipulation/add_bitwise_operator.py b/algorithms/bit_manipulation/add_bitwise_operator.py index 067656015..44d47907f 100644 --- a/algorithms/bit_manipulation/add_bitwise_operator.py +++ b/algorithms/bit_manipulation/add_bitwise_operator.py @@ -30,6 +30,8 @@ def add_bitwise_operator(first: int, second: int) -> int: >>> add_bitwise_operator(0, 0) 0 """ + if first < 0 or second < 0: + raise ValueError("The provided values must be non-negative!") while second: carry = first & second first = first ^ second