Binary Equation

Internally, values are usually binary (although you can assume they are anything you want,like ascii, bcd, etc.) So input routines take a decimal number and convert it to binary. Output routines take the binary and output as decimal.

If you want an algorithm for them, it's somewhat like this:

internal to base 10:
take the binary number
divide by 10, saving the remainder (which is a digit of the result) and the result
keep doing that to the result, successively peeling off digits until the result is zero
take this digits and output them in the reverse order you generated them

base 10 to internal:
take the input character, and convert to a digit (0-9)
multiply the internal number by 10,and add this digit
repeat to the internal number for each digit until all the input is 'used up'