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 support@ccsinfo.com

convert decimal to binary

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



Joined: 03 Aug 2010
Posts: 38

View user's profile Send private message MSN Messenger

convert decimal to binary
PostPosted: Sun Dec 18, 2011 10:38 pm     Reply with quote

Hi. I want to know if exists a instruction that permit convert a decimal number to a binary. My problem is that I receive a data from rs232 in decimal and I need it in binary.

thanks all
dyeatman



Joined: 06 Sep 2003
Posts: 1924
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Dec 18, 2011 10:49 pm     Reply with quote

Do you mean the decimal data is in ASCII character form?
_________________
Google and Forum Search are some of your best tools!!!!
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Mon Dec 19, 2011 7:08 am     Reply with quote

as mentioned before, you need to be clear if the data is comming as ASCII or not..

if its ascii numbers, just substract 30...(0-9) - for letters... its somthing similar...

please take into acount that once you "translate" your Ascii to hex, its already in binary....
you can perform bitwise operations on hex numbers...like if they where binary... although you "see" 0xAB you in reality have "b10101011"

the complier does all the work for you...

int x = 10; // Dec
int x = 0x0A; // Hex
int x = b00001010; // bin

its all the same....


G
_________________
CCS PCM 5.078 & CCS PCH 5.093
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