Skip to main content

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


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 details)

Uploaded Source

File details

Details for the file gatepy-1.0.0.tar.gz.

File metadata

  • Download URL: gatepy-1.0.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

File hashes

Hashes for gatepy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ed2e2403c56c67a0dd0c0aa4f0e26e96db057c06f2bf9dd0f9a417516e1f359e
MD5 4cb1123b4698c1ac50262984a5004622
BLAKE2b-256 beb02a11be1b6308113018dae052e7c522363e7401cbbb53a666c42416f2d720

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page