By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,515 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,515 IT Pros & Developers. It's quick & easy.

Convert Binnary num to decimal?

P: 1
hi,
i`m wowrking in project that accept user input from swtiches(on /off) which is binary and then i have to display that number in lcd via maicrocontroller.I'm using c interactive language.My question is do i have to convert that number the user inter to decimal number or the c automatically convert it.If not how i can convert it to decimal?
Nov 27 '06 #1
Share this Question
Share on Google+
2 Replies


sivadhas2006
100+
P: 142
Hi,

on/off representes 1/0 right.

If it is 1/0 means no need to convert to decimal.

Regards,
M.Sivadhas.
Nov 27 '06 #2

Expert 100+
P: 1,510
hi,
i`m wowrking in project that accept user input from swtiches(on /off) which is binary and then i have to display that number in lcd via maicrocontroller.I'm using c interactive language.My question is do i have to convert that number the user inter to decimal number or the c automatically convert it.If not how i can convert it to decimal?
usually the problem is that the LCD can only accept characters so you need to covert the switch value into a character string to display it, e.g. assume your switch value is in the variable switch and the function LCDdisplay() displays a char[] array
Expand|Select|Wrap|Line Numbers
  1. char text[50];                          /* text displaying switch value */
  2. sprintf(text, "switch = %d", switch);    /* convert switch value */                 
  3. LCDdisplay( text);                       /* display text */
  4.  
Nov 27 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.