Hello!
So you're interested only in positive numbers, right?
Why do you perform a division by hand?
You have a number of 2 digits. For example 69.
If you do 69/10, you get 6
If you do 69%10, you get 9.
Then why not saying that retval is 16 * the number of tens and then add the number of units?
By the way, what will happen if you enter more than 100 in your function? You are talking about
tens but not hundreds and thousands.
Then for the bcd2bin, if you start with 0x69, then it's basically the same:
0x69 / 16 = 6
0x69 % 16 = 9. Then return 6*10 + 9.
By the way you don't need parentheses for return. return retval; is fine.
Dora.