refactor: Remove unnecessary if else condition (#4307)

All the operation is being done in an else condition for "if number >= 0"
This commit is contained in:
Elisha Hollander 2021-04-04 07:00:17 +03:00 committed by GitHub
parent e7e6cbfb8f
commit 0992498a10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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_length = len(bin(number)[3:]) # Find 2's complement of number
binary_number = bin(abs(number) - (1 << binary_number_length))[3:] binary_number = bin(abs(number) - (1 << binary_number_length))[3:]
binary_number = ( binary_number = (
("1" + "0" * (binary_number_length - len(binary_number)) + binary_number) "1" + "0" * (binary_number_length - len(binary_number)) + binary_number
if number < 0
else "0"
) )
if shift_amount >= len(binary_number): if shift_amount >= len(binary_number):