https://github.com/8dcc/binary-conversions
Tiny C program for converting to decimal, binary, octal and hexadecimal
https://github.com/8dcc/binary-conversions
Last synced: about 2 months ago
JSON representation
Tiny C program for converting to decimal, binary, octal and hexadecimal
- Host: GitHub
- URL: https://github.com/8dcc/binary-conversions
- Owner: 8dcc
- License: gpl-3.0
- Created: 2022-09-25T10:18:02.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-21T07:49:07.000Z (over 3 years ago)
- Last Synced: 2025-11-11T22:30:56.801Z (8 months ago)
- Language: C
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Binary conversions
Tiny C program for converting to decimal, binary, octal and hexadecimal
## Installation
Download compiled binaries from the [releases](https://github.com/r4v10l1/binary-conversions/releases/latest) tab or build the source code using make:
```bash
git clone https://github.com/r4v10l1/binary-conversions
cd binary-conversions
make
./conversor.out --help
```
## Usage
### Decimal
*Syntax:*
```bash
# Note that 'd' can be any word starting with 'd', like 'dec' or 'decimal'
conversor.out d
```
*Example:*
```console
$ ./conversor.out decimal 420
Dec: 420
Bin: 110100100
Oct: 644
Hex: 1A4
```
### Binary
*Syntax:*
```bash
# Note that 'b' can be any word starting with 'b', like 'bin' or 'binary'
conversor.out b
```
*Example:*
```console
$ ./conversor.out binary 111011
Dec: 59
Bin: 111011
Oct: 73
Hex: 3B
```
### Octal
*Syntax:*
```bash
# Note that 'o' can be any word starting with 'o', like 'oct' or 'octal'
conversor.out o
```
*Example:*
```console
$ ./conversor.out octal 1337
Dec: 735
Bin: 1011011111
Oct: 1337
Hex: 2DF
```
### Hexadecimal
*Syntax:*
```bash
# Note that because of type sizes in c, very big numbers fail
# Note that 'h' can be any word starting with 'h', like 'hex' or 'hexadecimal'
conversor.out h
```
*Example:*
```console
$ ./conversor.out hex AE
Dec: 174
Bin: 10101110
Oct: 256
Hex: AE
```
## Compensate
```c
make compensate.out
./compensate.out < item-list.txt
```
You can see an example of `conversor` and `compensate` in [`misc/binary-table.sh`](misc/binary-table.sh).
## Old method
An old and worse method can be found on the [`old-conversions`](https://github.com/r4v10l1/binary-conversions/tree/old-conversions) branch.