2023-06-25 15:14:06 +02:00
|
|
|
#ifndef __LIBCPROJECT_CONVERT__
|
|
|
|
#define __LIBCPROJECT_CONVERT__
|
2023-01-05 19:28:05 +01:00
|
|
|
|
2023-08-07 00:11:07 +02:00
|
|
|
#include <errno.h>
|
2023-01-07 19:38:01 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "character.h"
|
|
|
|
#include "mathematics.h"
|
|
|
|
#include "stdbool.h"
|
|
|
|
#include "string.h"
|
2023-06-25 15:07:34 +02:00
|
|
|
#include "types.h"
|
2023-01-07 19:38:01 +01:00
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert a character to a string.
|
|
|
|
*
|
|
|
|
* @param character
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return string_t
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2023-06-25 15:03:04 +02:00
|
|
|
string_t convert_character_to_string(const char character);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert a character to a digit.
|
|
|
|
*
|
|
|
|
* @param character
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return char
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2023-01-05 19:28:05 +01:00
|
|
|
char convert_character_to_digit(const char character);
|
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert a digit to a character.
|
|
|
|
*
|
|
|
|
* @param digit
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return char
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2023-01-05 19:28:05 +01:00
|
|
|
char convert_digit_to_character(const char digit);
|
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert a string to a number.
|
|
|
|
*
|
2023-08-06 23:17:07 +02:00
|
|
|
* @param string
|
2024-09-25 14:26:15 +02:00
|
|
|
* @return int64_t
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2024-09-25 14:26:15 +02:00
|
|
|
int64_t convert_string_to_number(const string_t string);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert a number to a string.
|
|
|
|
*
|
|
|
|
* @param integer
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return string_t
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2024-09-25 14:26:15 +02:00
|
|
|
string_t convert_number_to_string(const int64_t integer);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert a number (base 10) to a string with a specific base.
|
|
|
|
*
|
|
|
|
* @param number
|
|
|
|
* @param base
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return string_t
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2024-09-25 14:26:15 +02:00
|
|
|
string_t convert_number_from_base_10_to_base(uint64_t number, uint64_t base);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert a number with a specific base to a number base 10.
|
|
|
|
*
|
|
|
|
* @param number
|
|
|
|
* @param base
|
2024-09-25 14:26:15 +02:00
|
|
|
* @return uint64_t
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2024-09-25 14:26:15 +02:00
|
|
|
uint64_t convert_number_from_base_to_base_10(string_t number, uint64_t base);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
2023-06-24 21:06:45 +02:00
|
|
|
/**
|
|
|
|
* @brief Convert a number with a specific base to a number of specific base.
|
|
|
|
*
|
|
|
|
* @param number
|
|
|
|
* @param base_from
|
|
|
|
* @param base_target
|
2023-08-09 21:08:15 +02:00
|
|
|
* @return string_t
|
2023-06-24 21:06:45 +02:00
|
|
|
* @since v1.0.0
|
|
|
|
*/
|
2024-09-25 14:26:15 +02:00
|
|
|
string_t convert_number_from_base_to_another(string_t number, uint64_t base_from, uint64_t base_target);
|
2023-01-05 19:28:05 +01:00
|
|
|
|
|
|
|
#endif
|