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
Release files for gatepy 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gatepy-1.0.2.tar.gz | 3.4 kB | Details |
Release files / gatepy-1.0.2.tar.gz
| Download URL | gatepy-1.0.2.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad46c3e1cc02939433ff5a756be6880f4f2a40823a8a0447450272df01504a94
|
|
BLAKE2b-256 checksum How to use checksums |
2286501fa1af1dda99f13f8e14352ee47e7e49aae387466b9fc0709afe9c2a39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/3.7.2 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.5
|