A simple and efficient command line numeric system conversion tool written in C. Supports binary, decimal, hexadecimal and octal
Find a file
2024-06-15 21:11:26 -04:00
.gitignore Initial commit 2024-06-15 21:09:51 -04:00
LICENSE Initial commit 2024-06-15 21:09:51 -04:00
Makefile Added code 2024-06-15 21:11:26 -04:00
README.md Added code 2024-06-15 21:11:26 -04:00
snconverter.c Added code 2024-06-15 21:11:26 -04:00

snconverter

Table of Contents

Introduction

snconverter is a command-line utility designed to convert numbers between different systems: decimal, binary, hexadecimal, and octal. It supports conversion from any of these number systems to any other, providing a versatile tool for developers, students, and anyone needing to perform such conversions regularly.

Building

This tool is provided as source code and can be built using make. By just typing make in the terminal within the code's directory:

make

You should now have an executable named snconverter. You can copy it to a location in your PATH for easy access.

Usage

To use the snconverter, run the executable from the command line with the appropriate options.

./snconverter [OPTIONS] <value>

Options

snconverter accepts the following options:

  • -d, --decimal <value>:

    • Specify the input value is in decimal.
  • -b, --binary <value>:

    • Specify the input value is in binary.
  • -x, --hex <value>:

    • Specify the input value is in hexadecimal.
  • -o, --octal <value>:

    • Specify the input value is in octal.
  • -h, --help:

    • Display the help message and exit.
  • -v, --version:

    • Display the program version and exit.

Examples

  1. Convert a decimal number to binary, hexadecimal, and octal:
./snconverter -d 255

Output:

Binary: 11111111
Hexadecimal: FF
Octal: 377
  1. Convert a binary number to decimal, hexadecimal, and octal:
./snconverter -b 11010101

Output:

Decimal: 213
Hexadecimal: D5
Octal: 325
  1. Convert a hexadecimal number to decimal, binary, and octal:
./snconverter -x 1A3F

Output:

Decimal: 6719
Binary: 1101000111111
Octal: 15177
  1. Display help message:
./snconverter -h

This will display detailed usage instructions and available options.

  1. Display version:
./snconverter -v

This will show the current version of the program.

Notes

  • Input values must be valid numbers in their respective systems (e.g., no letters in binary).
  • This tool does not currently support floating-point numbers or numbers beyond the range of standard 32-bit integers.