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 = '0'
a = list(format(a, '016b'))[::-1]
b = list(format(b, '016b'))[::-1]
out = []
for i in range(16):
S = gatepy.toint(gatepy.XOR(gatepy.XOR(gatepy.tobool(a[i]), gatepy.tobool(b[i])), gatepy.tobool(c)))
c = gatepy.OR(gatepy.AND(gatepy.XOR(gatepy.tobool(a[i]), gatepy.tobool(b[i])), gatepy.tobool(c)),gatepy.AND(gatepy.tobool(a[i]),gatepy.tobool(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.0.tar.gz
(2.4 kB
view hashes)