how do you convert a double digit number, to a single digit in C
say, if you have 34 i want it to convert to,
3*10 + 4 does anyone know of a ready-made algo (or code)?
cheers!
Printable View
how do you convert a double digit number, to a single digit in C
say, if you have 34 i want it to convert to,
3*10 + 4 does anyone know of a ready-made algo (or code)?
cheers!
Why do you want to convert it to the algorithm? That ain't exactly a single digit as you stated in your threads title.
Kedaman that link just shows how to double the integer though.
Well the example shows how to do that, but thats not the point. I guessed he was asking for how to convert a string of digits to an integer.Quote:
Originally Posted by vbleet
You would need to first convert it into a string, then append the multiplication factor to each digit (char) in the string. The simplest way would involve converting each char back into an integer. There's probably some mathematical way of avoiding the second conversion, but I can't think of it right now.Quote:
Originally Posted by deane034