CLI tool for practicing two's complement representation of signed integers
Project description
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.
bin2decconverts a bitstring to an integer representation (a Pythonint).int2decconverts a Python integer to a binary bitstring (this requires a second argument, anintrepresenting 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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file twos_complement_practice-1.0.3.tar.gz.
File metadata
- Download URL: twos_complement_practice-1.0.3.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef71cbb58a9f809d4401d02a265199aa03055ebd0c2fcddc46b7f116ba0e61c9
|
|
| MD5 |
ec7819438f57467c559059ad46664556
|
|
| BLAKE2b-256 |
b11d4dbc6a8b7abc2b15ad062911a1475f92216500add29b281e1a8977f49399
|
File details
Details for the file twos_complement_practice-1.0.3-py3-none-any.whl.
File metadata
- Download URL: twos_complement_practice-1.0.3-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
229ba9b448ca889d0934751f1b8d34265d9c81b5a0bfaf86bee653a4cf709b9f
|
|
| MD5 |
f4bfba0bbd3bc70702ee670873162f15
|
|
| BLAKE2b-256 |
86c8e90c1c30e4d68bd28f5c6289a7b1d8993155dede22e67e2fe0d864139ce5
|