2022-03-12 19:46:44 +00:00
# Numericx
2022-03-16 14:31:49 +00:00
A command-line interface (CLI) program that converts a number (or text) from one numerical system into another different numerical system.
2022-03-12 19:46:44 +00:00
## Compiling
This program create an executable (or many) that will convert a number from one numerical system into another one.
For example, you may want to convert a hexadecimal number into a ternary number. You may use this program.
You first need to define the proprieties of the numerical systems. These proprieties are defined in the compilation process (as compilation flags).
2022-03-13 22:44:15 +00:00
For example, let's make the hexdecimal numerical system with numerals from `0-f` , with a infinite 0 and it start counting on 1. So, our hexadecimal system will need the following compilation flags:
2022-03-12 19:46:44 +00:00
```
-DFROM_NUMERICALS=\"0123456789abcdef\" -DFROM_FIRST_NUMBER_VOID -DFROM_INFINITE_BASE
```
if you want the units place of this numerical system to be on the right side, add `-DFROM_UNITS_ON_THE_END` .
2022-03-13 22:44:15 +00:00
Now, for the ternary system let's make with numerals from `1-3` , 1 is not infinite and it start counting on 1. Use this flags:
2022-03-12 19:46:44 +00:00
```
-DTO_NUMERICALS=\"123\"
```
if you want the units place of this numerical system to be on the right side, use `-DTO_UNITS_ON_THE_END` .
Now, to create the executable to translate a number for these two numerical system, join all of this together and compile using this:
```
2022-03-13 22:44:15 +00:00
$ c99 -DFROM_NUMERICALS=\"0123456789abcdef\" -DFROM_FIRST_NUMBER_VOID -DFROM_INFINITE_BASE -DFROM_UNITS_ON_THE_END -DTO_NUMERICALS=\"123\" -DTO_UNITS_ON_THE_END numericx.c -o hex-to-ternary
2022-03-12 19:46:44 +00:00
```
2022-03-13 22:44:15 +00:00
This creates the `hex-to-ternary` executable with can be used to convert numbers from hexadecimal to ternary!
2022-03-12 19:46:44 +00:00
## Pre-defined executable compilation
2022-03-13 22:44:15 +00:00
There are many pre-defined compilation of executables on the Makefile. Take a look at the Makefile to know them.
2022-03-12 19:46:44 +00:00
Or you can run `make` to get all of the pre-defined executables. `make clean` to delete them.
## Compilation flags meanings
2022-03-13 22:44:15 +00:00
There are two categories for the compilation flags: the `FROM` category and the `TO` category.
2022-03-12 19:46:44 +00:00
2022-03-13 22:44:15 +00:00
`FROM` flags are the numerical system definitions of the argument number.
2022-03-12 19:46:44 +00:00
2022-03-13 22:44:15 +00:00
`TO` flags are the numerical system definitions of the number result.
2022-03-12 19:46:44 +00:00
2022-03-13 22:44:15 +00:00
Below, are the meanings of the `FROM` flags. The `TO` flags are the same as the `FROM` flags, with a switch of the `FROM_` to a `TO_` .
2022-03-12 19:46:44 +00:00
|Flag|Meaning|
|---|---|
|FROM_NUMERALS|Define the numerical system numerals of the 'from'|
|FROM_UNITS_ON_THE_END|Defines the units case to be on the end (on the right) for the 'from'|
|FROM_FIRST_NUMBER_VOID|Defines the first number as a "not counting" for the 'from'|
|FROM_INFINITE_BASE|Defines the first number to be infinite, for the 'from' (for example, if the first numeral is 0, then 0 == 00 == 000 == 0000 ... . Or if the first numeral is 1, then 1 == 11 == 111 ...)|
There is also the `DEBUG` flag, which will show all the steps that you number walked through. Remember: you use `-DDEBUG` as an compiler argument.
2022-03-16 17:39:28 +00:00
## Documentation
See [numericx documentation page ](https://dacs-git.codeberg.page/numericx/ ). Look at `Files > File List` in the documentation menubar website.
2022-03-12 19:46:44 +00:00
## License
MIT
## Author
Daniel A. C. Santos