# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

x = -9

print(x)
print(bin(x))

print(bin(x & 0xff))
print(format(x & 0xffff, 'x'))

x = 9   # 0b1001
y = 10  # 0b1010

print(x & y)
print(bin(x & y))

print(x | y)
print(bin(x | y))

print(x ^ y)
print(bin(x ^ y))

x = 9  # 0b1001

print(~x)
print(bin(~x))

print(bin(~x & 0xff))
print(format(~x & 0b1111, '04b'))

x = 9  # 0b1001

print(x << 1)
print(bin(x << 1))

print(x >> 1)
print(bin(x >> 1))

x = -9
print(bin(x))
print(bin(x & 0xff))

print(x << 1)
print(bin(x << 1))
print(bin((x << 1) & 0xff))

print(x >> 1)
print(bin(x >> 1))
print(bin((x >> 1) & 0xff))

StarcoderdataJupyterScriptsDedupFiltered