You are here:

C/converting hexadecimal to decimal by divsion?

Advertisement


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  

Answer
This 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.

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

©2012 About.com, a part of The New York Times Company. All rights reserved.