mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
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:
parent
e7e6cbfb8f
commit
0992498a10
|
@ -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):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user