Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 10th April 2004, 03:42 PM   (permalink)
Default Hex to decimal

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 is offline  
Old 7th May 2005, 01:21 AM   (permalink)
Default Re: Hex to decimal

Quote:
Originally Posted by radialspel
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.

__________________
Madhav Joshi
91 22 26144826
9821835920
madhavjj@msp430total.com
madhavjj is offline  
Old 7th May 2005, 06:06 AM   (permalink)
Default

dosent your compiler have an manual or a list explaning commands?
__________________
Il give you shocking experience.
Someone Electro is offline  
Old 7th May 2005, 09:17 AM   (permalink)
Default

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?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 7th May 2005, 12:49 PM   (permalink)
Default

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.
plot is offline  
Old 9th May 2005, 04:12 AM   (permalink)
Default

What is the context of your question? Are you needing to convert a string to a number?

Dan East
Dan East is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 05:34 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker