Browse Source

refactoring: added comments describing the function's behavior and use in header file

remotes/origin/conversionOfNumbers
Laurin 11 months ago
parent
commit
004b81aca4
  1. 20
      src/conversionOfNumbers/conversionOfNumbers.h

20
src/conversionOfNumbers/conversionOfNumbers.h

@ -1,11 +1,31 @@
#ifndef CONVERSIONOFNUMBERS_H #ifndef CONVERSIONOFNUMBERS_H
#define 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); 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); 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); 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); 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); 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); unsigned int convertHexStrToInt(char* input);
#endif #endif
Loading…
Cancel
Save