-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from sntdrr/any-base-overhaul
completely overhauled code, now accepts any bases
- Loading branch information
Showing
2 changed files
with
172 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.