Skip to content
Snippets Groups Projects
Commit 81c71792 authored by Brandon Rodriguez's avatar Brandon Rodriguez
Browse files

Clean up DivAlg.c

parent 1be58a7f
Branches
No related merge requests found
......@@ -33,8 +33,8 @@ char* ToBaseTen(char* input, unsigned int base) {
char outputString[32]; // String for output values.
char* remainderTable = "0123456789ABCDEF";
// Copy from input to outputString.
strncpy(outputString, input, stringLength);
printf(" Input Pre-Swap: %s", outputString);
// Create swap pointers and swap values.
stringLength--;
......@@ -47,26 +47,17 @@ char* ToBaseTen(char* input, unsigned int base) {
strPointer2--;
}
printf(" Input Post-Swap: %s", outputString);
// Do math to find base 10 values.
tempInt1 = 0;
for (index = 0; index <= stringLength; index++) {
tempInt2 = (input[index] - '0');
printf("\n TempInt2 = %u ", tempInt2);
printf(" Calculating...Index: %u", tempInt2);
printf(" TempInt Prior to Math: %u", tempInt1);
tempInt1 = (tempInt1 * base);
printf(" T * B = %u", tempInt1);
tempInt1 = (tempInt1 + tempInt2);
printf(" Calculating...Math'd: %u", tempInt1);
tempInt1 = (tempInt1 * base + tempInt2);
}
printf(" Post-Math Int: %u", tempInt1);
// Create buffer to pass back.
//char* buffer = outputString;
sprintf(outputString, "%u", tempInt1);
char* buffer = outputString;
return buffer;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment