Skip to main content

A REPL for bitwise and arithmetic operations with multi-format output

Project description

bitrepl

A REPL for bitwise and arithmetic operations. See results in hex, binary, and decimal (signed/unsigned) simultaneously.

Built for C systems programming courses.

Installation

pip install bitrepl

Usage

bitrepl
[32-bit] > 0xFF & 0x0F
$0:
  Hex:       0x0000000F
  Binary:    0000 0000 0000 0000 0000 0000 0000 1111
  Unsigned:  15
  Signed:    15

[32-bit] > ~0
$1:
  Hex:       0xFFFFFFFF
  Binary:    1111 1111 1111 1111 1111 1111 1111 1111
  Unsigned:  4294967295
  Signed:    -1

Features

  • Multi-format output: Every result shows hex, binary, unsigned, and signed representations
  • C-style operators: & | ^ ~ << >> + - * / %
  • Number formats: Decimal (255), hex (0xFF), binary (0b1111), octal (0o17)
  • Configurable bit width: 8, 16, 32, or 64 bits
  • Result comparison: Compare multiple results side-by-side
  • Variables: Store and reuse values

Commands

Command Description
:width N Set bit width (8, 16, 32, 64)
:cmp Compare last 2 results side-by-side
:cmp N Compare last N results
:vars Show stored variables
:clear Clear result history
:help Show help
:quit Exit

Variables

Reference previous results with $0, $1, etc:

[32-bit] > 0xFF
$0: ...

[32-bit] > $0 << 8
$1: ...

Store named variables:

[32-bit] > $mask = 0xFF
[32-bit] > 0xABCD & $mask

Comparison

Compare signed vs unsigned interpretation of the same bit pattern:

[8-bit] > 127
[8-bit] > 128
[8-bit] > :cmp
======================================================
COMPARISON:
------------------------------------------------------
          127                   128
------------------------------------------------------
Hex:      0x7F                  0x80
Binary:   0111 1111             1000 0000
Unsigned: 127                   128
Signed:   127                   -128
======================================================

License

MIT

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

bitrepl-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitrepl-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file bitrepl-0.1.0.tar.gz.

File metadata

  • Download URL: bitrepl-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for bitrepl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5805ac4e0fccdacecc045aa492511c376baaaf3b2fc3f42ed78aebba34288f4a
MD5 d052b4e6d8304cb49a58d424484f2012
BLAKE2b-256 667c74f462b645a0d784f5be7e7e70c03d63f95f560c8616c438884077a6a487

See more details on using hashes here.

File details

Details for the file bitrepl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bitrepl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for bitrepl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a96e73f22f320c89975bd36d6a553008eac01724645f9bcc2271d13d28afdfe1
MD5 92b7eea35c25d7f1d4721097640720d8
BLAKE2b-256 ab03ac02117644649ac5677ebf9fe5ca88acb695e6b704ecc7e3ff0e97a7691e

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