Skip to main content
Navigation
HomeTechnical ReferenceJournalGitHubGitHub
Sidebar — toggle document categories via the logo
Binary Converter — CLI Number Conversion Tool

Binary Converter — CLI Number Conversion Tool

July 30, 2020

Overview

Binary Converter is a lightweight Python CLI tool for converting numbers between decimal (base-10) and binary (base-2) representations. It provides a clean command-line interface using Python's argparse module and includes a test suite that validates conversion accuracy. GitHub Actions runs the test suite automatically on every push to ensure correctness.


Key Features

  • Dual conversion modes: Convert decimal integers to binary, or binary strings to decimal
  • Clean CLI interface: User-friendly help text via python convert.py --help
  • Automated testing: GitHub Actions CI pipeline runs the test suite on every push
  • Simple setup: Single-file implementation with minimal dependencies

Usage

# Convert decimal to binary
python convert --decimal 42
# Output: 101010

# Convert binary to decimal
python convert --binary 101010
# Output: 42

# Display help
python convert.py --help

The converter handles positive integers using standard conversion algorithms — repeated division by 2 for decimal-to-binary, and positional notation summation for binary-to-decimal.


Tech Stack

LayerTechnology
LanguagePython 3
CLIargparse
CI/CDGitHub Actions
BuildMakefile