Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Hex to decimal

Status
Not open for further replies.

radialspel

New Member
How can i make to convert from hex to decimal in c-code?? The program must convert everything from 0x000 to 0x3FF to decimal! I´m using the CC5X C-compiler.
 
radialspel said:
How can i make to convert from hex to decimal in c-code?? The program must convert everything from 0x000 to 0x3FF to decimal! I´m using the CC5X C-compiler.


Dear sir,
I am having the same problem. Have your figured out some simple way?
I will appreciate if you send me code snippet to guide me how to go about solving this. Please.

 
I don't use C, but surely any compiler will give you the option of displaying in at least binary, hexadecimal, or decimal - there shouldn't be any programming involved?.
 
You gotta write code that multiples each value of the hex number by 16 to the power of which place each hex number is.

For example, look at this chart for converting the hex number F111h

Code:
4096 |  256 |   16 |    1
16^3 | 16^2 | 16^1 | 16^0
   F |    1 |    1 |    1h

we multiply 1 by 16^0 power to get a 1.
then we multiply 1 by 16^1 to get 16.
then we multiply 1 by 16^2 to get 256.
then we multiply F by 16^3 to get 61440.

then we add 1 + 16 + 256 + 61440 to get the decimal value of F111h, which is 61713.

So, now that you know the steps, create a flow chart to see what's going on, and work on your C code from there.
 
Status
Not open for further replies.

Latest threads

Back
Top