C/converting hexadecimal to decimal by divsion?
Expert: Narendra - 8/7/2006
Question
-------------------------
Followup To
Question -
Hi Narendra,
Is it possible to convert from Hexadecimal to decimal by a division algorithm? I am looking to do this for an embedded ARM core cpu application.
It would be more economical to do it this way, so I have been informed but I am not familiar.
I would normally associate division with decimal to hex conversion. Please advise
Regards,
Trevor McCook
Answer -
Who told you that division is economical.
I think multiplication will be more economical than division.
If somebody can prove me wrong, I will be very happy.
Hi Narendra,
Thank you for the reply, although I do not think you have answered the question. I must ask again, can Hex to decimal conversion be done by division or not?
Regards,
Trevor McCook
AnswerThis is a mathematics question. (Nothing related to C programming)
As I know from maths, hex to decimal can be achived by multiplying each digit by multiples of 16.
So, reply to your question is: "Hex to Decimal by division is not possible.
But, if you understand the workings of a computer, everything boils down to binary numbers.
Then both multiplication and division is nothing but "Left Shift" or "Right Shift".
There is no such thing as "Division" in binary arithmetic.
Hope you understand what I am trying to say.