From 8f47d9f807fae641bffe97ee28ea2e213c2818d8 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 24 Dec 2020 18:16:44 +0530 Subject: [PATCH] Fix type annotations for bit manipulation algorithms (#4056) --- bit_manipulation/binary_and_operator.py | 2 +- bit_manipulation/binary_or_operator.py | 2 +- bit_manipulation/binary_xor_operator.py | 2 +- bit_manipulation/single_bit_manipulation_operations.py | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bit_manipulation/binary_and_operator.py b/bit_manipulation/binary_and_operator.py index f1b910f8c..191ff8eb4 100644 --- a/bit_manipulation/binary_and_operator.py +++ b/bit_manipulation/binary_and_operator.py @@ -1,7 +1,7 @@ # https://www.tutorialspoint.com/python3/bitwise_operators_example.htm -def binary_and(a: int, b: int): +def binary_and(a: int, b: int) -> str: """ Take in 2 integers, convert them to binary, return a binary number that is the diff --git a/bit_manipulation/binary_or_operator.py b/bit_manipulation/binary_or_operator.py index e83a86d6a..dabf5bcb0 100644 --- a/bit_manipulation/binary_or_operator.py +++ b/bit_manipulation/binary_or_operator.py @@ -1,7 +1,7 @@ # https://www.tutorialspoint.com/python3/bitwise_operators_example.htm -def binary_or(a: int, b: int): +def binary_or(a: int, b: int) -> str: """ Take in 2 integers, convert them to binary, and return a binary number that is the result of a binary or operation on the integers provided. diff --git a/bit_manipulation/binary_xor_operator.py b/bit_manipulation/binary_xor_operator.py index 0edf2ba66..6f8962192 100644 --- a/bit_manipulation/binary_xor_operator.py +++ b/bit_manipulation/binary_xor_operator.py @@ -1,7 +1,7 @@ # https://www.tutorialspoint.com/python3/bitwise_operators_example.htm -def binary_xor(a: int, b: int): +def binary_xor(a: int, b: int) -> str: """ Take in 2 integers, convert them to binary, return a binary number that is the diff --git a/bit_manipulation/single_bit_manipulation_operations.py b/bit_manipulation/single_bit_manipulation_operations.py index 114eafe32..e4a54028d 100644 --- a/bit_manipulation/single_bit_manipulation_operations.py +++ b/bit_manipulation/single_bit_manipulation_operations.py @@ -3,7 +3,7 @@ """Provide the functionality to manipulate a single bit.""" -def set_bit(number: int, position: int): +def set_bit(number: int, position: int) -> int: """ Set the bit at position to 1. @@ -21,7 +21,7 @@ def set_bit(number: int, position: int): return number | (1 << position) -def clear_bit(number: int, position: int): +def clear_bit(number: int, position: int) -> int: """ Set the bit at position to 0. @@ -37,7 +37,7 @@ def clear_bit(number: int, position: int): return number & ~(1 << position) -def flip_bit(number: int, position: int): +def flip_bit(number: int, position: int) -> int: """ Flip the bit at position.