Skip to main content

Two's Complement Practice Tool

This is a command-line tool for practicing and reviewing two's complement representation of signed integers.

Developed for CS2210 (Computer Organization) at the University of Vermont by Clayton Cafiero.


Installation

pip install twos-complement-practice

Usage

After installing:

$ twos-practice

You will be prompted to choose a bit width (e.g., 4, 8, etc.). The program will then randomly select from three activity types:

  • Additive inverse: Given a bitstring, provide the additive inverse in two's complement form.
  • Decimal to bitstring: Convert a signed decimal integer to two's complement binary.
  • Bitstring to decimal: Convert a two's complement binary string to a decimal integer.

You can exit at any prompt by typing q.

At the end, you'll get a summary of your performance and a list of any incorrect responses.

Running in Python or your IDE

You can also import and run the tool interactively:

import twos_complement_practice as tcp
tcp.run()

Utility functions

The module also exposes two utility functions, bin2dec and dec2bin.

  • bin2dec converts a bitstring to an integer representation (a Python int).
  • int2dec converts a Python integer to a binary bitstring (this requires a second argument, an int representing the number of bits to use).

Educational goals

This tool is designed to:

  • reinforce understanding of signed binary number representation,
  • develop fluency with two's complement conversions, and
  • provide low-stakes, interactive feedback for learners.

License

This project is licensed under the terms of the GNU General Public License v3.0.

You are free to use, modify, and distribute this software under the conditions specified in the license.

© 2025 Clayton Cafiero
For inquiries, contact cbcafier@uvm.edu


Dependencies

  • colorama: for cross-platform colored terminal output.

Metadata

Release files for twos-complement-practice 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for twos-complement-practice 1.0.3
File Size Uploaded Provenance Actions
twos_complement_practice-1.0.3.tar.gz 7.2 kB Without provenance Details for twos_complement_practice-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for twos-complement-practice 1.0.3
File Interpreter ABI Platform Actions
twos_complement_practice-1.0.3-py3-none-any.whl Python 3 none any Details for twos_complement_practice-1.0.3-py3-none-any.whl

Total release size: 14.4 kB

Release files / twos_complement_practice-1.0.3.tar.gz

Download URL twos_complement_practice-1.0.3.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ef71cbb58a9f809d4401d02a265199aa03055ebd0c2fcddc46b7f116ba0e61c9
BLAKE2b-256 checksum
How to use checksums
b11d4dbc6a8b7abc2b15ad062911a1475f92216500add29b281e1a8977f49399
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release files / twos_complement_practice-1.0.3-py3-none-any.whl

Download URL twos_complement_practice-1.0.3-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
229ba9b448ca889d0934751f1b8d34265d9c81b5a0bfaf86bee653a4cf709b9f
BLAKE2b-256 checksum
How to use checksums
86c8e90c1c30e4d68bd28f5c6289a7b1d8993155dede22e67e2fe0d864139ce5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Security for twos-complement-practice 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page