From 004b81aca4d896786bb445f3670360c57f3b2dd5 Mon Sep 17 00:00:00 2001 From: Laurin Date: Sat, 3 Feb 2024 11:42:31 +0100 Subject: [PATCH] refactoring: added comments describing the function's behavior and use in header file --- src/conversionOfNumbers/conversionOfNumbers.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/conversionOfNumbers/conversionOfNumbers.h b/src/conversionOfNumbers/conversionOfNumbers.h index 3718fcc..c42a225 100644 --- a/src/conversionOfNumbers/conversionOfNumbers.h +++ b/src/conversionOfNumbers/conversionOfNumbers.h @@ -1,11 +1,31 @@ #ifndef CONVERSIONOFNUMBERS_H #define CONVERSIONOFNUMBERS_H +// This function converts an integer into a string of according binary digits. If the integer is below zero, +// a minus sign will be added in front of the string of binary digits. +// For the sake of simplicity there will be no use of the two's complement. +// Note: if allocation of memory doesn't work correctly, function will return NULL. char* convertIntToBinaryStr(int input); + +// This function determines the length of the string needed for the representation of an integer in binary digits. int binaryStrLen(int input); + +// This function converts a string of binary digits into the according decimal number. +// For the sake of simplicity it can only convert positive numbers into unsigned integers. unsigned int convertBinaryStrToInt(char* input); + +// This function converts an integer into an according string representing the integer in the hexadecimal system. +// Note: Need to check if the input integer is positive as implementation for converting negative integers +// is not done yet (for the sake of time). +// Note: if allocation of memory doesn't work correctly, function will return NULL. char* convertIntToHex(int input); + +// This function determines the length of the string needed for the representation of an integer +// in the hexadecimal system. int hexStrLen(const int input); + +// This function converts a hexadecimal number as a string into the according decimal number. +// For the sake of simplicity it can only convert positive numbers into unsigned integers. unsigned int convertHexStrToInt(char* input); #endif \ No newline at end of file