From 0992498a107267ccbfc7ab2c72045c31a537ab25 Mon Sep 17 00:00:00 2001 From: Elisha Hollander Date: Sun, 4 Apr 2021 07:00:17 +0300 Subject: [PATCH] refactor: Remove unnecessary if else condition (#4307) All the operation is being done in an else condition for "if number >= 0" --- bit_manipulation/binary_shifts.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bit_manipulation/binary_shifts.py b/bit_manipulation/binary_shifts.py index fe62880f9..50dc27ffe 100644 --- a/bit_manipulation/binary_shifts.py +++ b/bit_manipulation/binary_shifts.py @@ -91,9 +91,7 @@ def arithmetic_right_shift(number: int, shift_amount: int) -> str: binary_number_length = len(bin(number)[3:]) # Find 2's complement of number binary_number = bin(abs(number) - (1 << binary_number_length))[3:] binary_number = ( - ("1" + "0" * (binary_number_length - len(binary_number)) + binary_number) - if number < 0 - else "0" + "1" + "0" * (binary_number_length - len(binary_number)) + binary_number ) if shift_amount >= len(binary_number):