No project description provided
Project description
gatepy
gatepy is a Python implementation of a logical gate.
Installation
Open console and run the following command:
pip install gatepy
Done.
Examples
Adder
import gatepy
def adder(a, b):
c = False
a = list(format(a, "064b"))[::-1]
b = list(format(b, "064b"))[::-1]
out = []
for i in range(64):
S = int(
gatepy.XOR(
gatepy.XOR(int(a[i]), int(b[i])), c
)
)
c = gatepy.OR(
gatepy.AND(
gatepy.XOR(int(a[i]), int(b[i])), c
),
gatepy.AND(int(a[i]), int(b[i])),
)
out.append(str(S))
return int("".join(out[::-1]), 2)
print(adder(1, 2))
Return:
3
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gatepy-1.0.2.tar.gz
(3.4 kB
view hashes)