#include #include "converters.h" #include using namespace std; char IntToDecimalDigit(int value) { char digit{'x'}; if (value >= 0 and value <= 9) { digit = static_cast(value + '0'); } else { cout << "Error: in IntToDecimalDigit" << value << " is not a valid decimal digit " << endl; } return digit; } int DecimalDigitToInt(char digit) { int returnValue{0}; if (isdigit(digit)) { returnValue = digit -'0'; }else { cout << "Error: in DecimalDigitToInt " << digit << " is not a valid decimal digit " << endl; } return returnValue; } string IntegerToString(int value) { string number; int digit; if (value == 0) { number = "0"; } else { while (value > 0) { digit = value % 10; value = value / 10; number = IntToDecimalDigit(digit) + number; } } return number; } int StringToInteger(string num){ int value{0}; size_t i; for(i = 0; i < num.size() ; ++i) { value = value * 10 + DecimalDigitToInt(num[i]); } return value; }