This is a simple C library that provides a function to convert a binary number to its decimal representation.
To build the library, run make
in the root directory. This will generate the library file in the lib directory.
To build the example program, run make
in the example repository. This will generate the executable in the bin
directory.
To use this library in your C project, simply copy the files in the src
and include
directories to your project directory, and include the binary_to_decimal.h
header file in your source code.
Alternatively, you can install this library using a package manager like GitHub Packages.
Include the binary_to_decimal.h
header file in your project, and link against the binary_to_decimal
library.
#include "binary_to_decimal.h"
int main() {
int binary = 1010;
printf("Decimal number is: %d\n", binary_to_decimal(binary));
return 0;
}
An example program is provided in the tq-binary-to-decimal-example repository. To build the example program, clone the repository and run make
in the example directory. This will generate the executable in the bin
directory.
If you prefer to use this library via GitHub Packages, you can follow these steps:
-
Make sure you have Docker installed on your machine.
-
Pull the Docker image that contains the library by running the following command:
docker pull ghcr.io/toolquarry/tq-binary-to-decimal/tq-binary-to-decimal:latest
-
Create a new Docker container based on the image you pulled by running the following command:
docker run -it tq-binary-to-decimal /bin/bash
-
Inside the Docker container, navigate to the directory where the library is installed.
-
Compile your C code using the appropriate compiler commands, depending on how the library was built.
-
Once your C code is compiled, you can use the functions in the library by including the appropriate header files and linking against the library.
-
To copy the header files to your local system, exit the Docker container by typing exit in the terminal and run the following command:
docker cp <container-id>:<path-to-header-files> <local-path>
Replace
<container-id>
with the ID of the Docker container you just exited,<path-to-header-files>
with the path to the header files inside the container, and<local-path>
with the path on your local system where you want to copy the header files.You can check the container ID by running the following command:
docker ps -a
This will display a list of all Docker containers on your system, including the one you just exited. Make a note of the container ID.
-
Once the header files are copied to your local system, you can use them in your C code by including the appropriate header files and linking against the library when compiling.
Note that if the library has dependencies that are not installed on your local system, you may need to install those dependencies before you can use the library.
This library provides the following function:
int binary_to_decimal(int binary);
This project is licensed under the MIT License - see the LICENSE file for details.