Skip to main content

No project description provided

Project description

gatepy

made-with-python PyPI license PyPI version shields.io PyPI pyversions

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


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

Uploaded Source

File details

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

File metadata

  • Download URL: gatepy-1.0.2.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for gatepy-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ad46c3e1cc02939433ff5a756be6880f4f2a40823a8a0447450272df01504a94
MD5 56279931b66535848c03f737d2c629bf
BLAKE2b-256 2286501fa1af1dda99f13f8e14352ee47e7e49aae387466b9fc0709afe9c2a39

See more details on using hashes here.

Supported by

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