mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-10-06 05:39:30 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
7f6082004e
commit
c1a52b40ab
|
@ -1,5 +1,5 @@
|
|||
def update_bit(n: int, pos: int, value: int) -> int:
|
||||
'''
|
||||
"""
|
||||
It is a program to update a bit at given position
|
||||
|
||||
Details:update the bit at position pos of the
|
||||
|
@ -16,13 +16,14 @@ def update_bit(n: int, pos: int, value: int) -> int:
|
|||
7
|
||||
>>> update_bit(10,0,1) #0b1011
|
||||
11
|
||||
'''
|
||||
"""
|
||||
|
||||
mask = ~(1 << pos)
|
||||
n = n & mask
|
||||
return n | (value << pos)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import doctest
|
||||
|
||||
doctest.testmod()
|
||||
doctest.testmod()
|
||||
|
|
Loading…
Reference in New Issue
Block a user