snconverter/README.md

129 lines
2.5 KiB
Markdown
Raw Normal View History

2024-06-16 01:09:51 +00:00
# snconverter
2024-06-16 01:11:26 +00:00
## Table of Contents
- [Introduction](#introduction)
- [Building](#building)
- [Usage](#usage)
- [Options](#options)
- [Examples](#examples)
- [Notes](#examples)
## 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:
```bash
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.
```bash
./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:
2024-06-16 01:25:22 +00:00
```bash
./snconverter -d 255
```
Output:
```
Binary: 11111111
Hexadecimal: FF
Octal: 377
```
2024-06-16 01:11:26 +00:00
2. Convert a binary number to decimal, hexadecimal, and octal:
2024-06-16 01:25:22 +00:00
```bash
./snconverter -b 11010101
```
Output:
```
Decimal: 213
Hexadecimal: D5
Octal: 325
```
2024-06-16 01:11:26 +00:00
3. Convert a hexadecimal number to decimal, binary, and octal:
2024-06-16 01:25:22 +00:00
```bash
./snconverter -x 1A3F
```
Output:
```
Decimal: 6719
Binary: 1101000111111
Octal: 15177
```
2024-06-16 01:11:26 +00:00
4. Display help message:
2024-06-16 01:25:22 +00:00
```bash
./snconverter -h
```
This will display detailed usage instructions and available options.
2024-06-16 01:11:26 +00:00
5. Display version:
2024-06-16 01:25:22 +00:00
```bash
./snconverter -v
```
This will show the current version of the program.
2024-06-16 01:11:26 +00:00
## 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.