Skip to content

Commit

Permalink
Merge pull request #2 from sntdrr/any-base-overhaul
Browse files Browse the repository at this point in the history
completely overhauled code, now accepts any bases
  • Loading branch information
sdarre authored May 16, 2020
2 parents 6607e6c + 2ec2283 commit 7c7a9a3
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 186 deletions.
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
## hexc
Terminal program for converting to and from binary, decimal, and hexadecimal.
Terminal program for converting between bases.

To build, run `make`. To install, build and run `sudo make install`. To
uninstall, run `sudo make uninstall`.

Run `hexc {operator} {string1 string2 string3...}` to produce a converted string or series of strings.
Run `hexc {operator} {string1 string2 string3...}` or `hexc {-i[input base size] -o[output base size] {string1 string2 string3...}` to produce a converted string or series of strings.

The operators are as follows:

| Operator | Description | Limit (per string) |
| ---------|------------------------| ------------------------------------------------------|
| -bd | Binary to decimal | 11111111111111111111111111111111111111111111111111111 |
| -bh | Binary to hexadecimal | Unlimited. |
| -db | Decimal to binary | 18446744073709551615 |
| -dh | Decimal to hexadecimal | 18446744073709551615 |
| -hb | Hexadecimal to binary | Unlimited. |
| -hd | Hexadecimal to decimal | FFFFFFFFFFFFF |
| Operator | Description |
| ---------|------------------------|
| -bd | Binary to decimal |
| -bh | Binary to hexadecimal |
| -bo | Binary to octal |
| -db | Decimal to binary |
| -dh | Decimal to hexadecimal |
| -do | Decimal to octal |
| -hb | Hexadecimal to binary |
| -hd | Hexadecimal to decimal |
| -ho | Hexadecimal to octal |
| -ob | Octal to binary |
| -od | Octal to decimal |
| -oh | Octal to hexadecimal |

hexc can be fed several strings, separated by whitespace. For example:
hexc can be fed several strings, separated by whitespace. Bases can range from 2 to 36 (inclusive).

### Examples
```
~$ hexc -bd 10101 111
10101 -> 21
111 -> 7
~$ hexc -hb 3b9ac9ff ABC123
3B9AC9FF -> 00111011100110101100100111111111
ABC123 -> 101010111100000100100011
~$ hexc -i8 -o16
312 -> CA
```

### To-do
* Implement conversion to and from ASCII
* Implement the ability to feed text files as input
* Figure out some better way to implement HexToBin (I know it's ugly)
* Raise limit on BinToDec and HexToDec
* Fix bug of inaccurate output when converting very large numbers
Loading

0 comments on commit 7c7a9a3

Please sign in to comment.