CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

hexa to decimal display

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
balu



Joined: 13 Mar 2005
Posts: 5

View user's profile Send private message

hexa to decimal display
PostPosted: Sun Mar 20, 2005 1:26 pm     Reply with quote

hai,
i am reciving a data, i stored that data in one adress, but i want to display that value in decimal,,iam using pic 16f876, i just need any formula that can be applied in code to convert that hexa to decimal, if anyone has some idea, please reply me,, thanks a lot bye bye
valemike
Guest







PostPosted: Sun Mar 20, 2005 2:06 pm     Reply with quote

You want to display it with printf?

To show it in decimal:
printf("%d", data);

To show it in hex:
printf("0x%X", data); // will print it with capital letters.
"%x" will print it in lowercase letters.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Sun Mar 20, 2005 2:08 pm     Reply with quote

My first thought would be for you to use printf but most people would have looked into printf and solved this issue before going to this board, so maybe its something to do with the way numbers are represented that has you asking. Decimal and Hex are notations...a way to present to our eyes an underlying binary value that is stored as a collection of bytes inside the PIC. Thats where printf comes in. Perhaps you have data presented as two ascii chars representing the hexadecimal notation of the value. In which case take the first acsii char (0..F) and subtract the ascii value of the char "0" and multiply by 16 then take the second chars ascii value and subtract '0' and add it to the first char. If the result is stored in a byte then the value if the byte will be the decimal number you want only it is expressed in binary. To express this binary value in decimal notation
divide by ten take the remainder add the acii value of "0" and you have the least significant digit as an ascii char 0..9 ...repeat until you are done.
Want someone to write code for you then search under hex to integer and hex to decimal atoi etc.
balu



Joined: 13 Mar 2005
Posts: 5

View user's profile Send private message

hexa to decimal
PostPosted: Mon Mar 21, 2005 6:31 am     Reply with quote

yes, iam working in icd,, and my pic is connected with 2 seven segment displays, i am getting some value from temperature sensor,, and i need to display it on the sevensegment display,, but the value iam reciving is a hexadecimal value,, that value i have to convert to decimal then i have to display it,,now i think i make it clear what i need.
thanks a lot, have fun
dhanyavad
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group