Convert Binnary num to decimal?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kathi215
    New Member
    • Nov 2006
    • 1

    Convert Binnary num to decimal?

    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 maicrocontrolle r.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?
  • sivadhas2006
    New Member
    • Nov 2006
    • 142

    #2
    Hi,

    on/off representes 1/0 right.

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

    Regards,
    M.Sivadhas.

    Comment

    • horace1
      Recognized Expert Top Contributor
      • Nov 2006
      • 1510

      #3
      Originally posted by Kathi215
      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 maicrocontrolle r.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
      Code:
      char text[50];                          /* text displaying switch value */
      sprintf(text, "switch = %d", switch);    /* convert switch value */                 
      LCDdisplay( text);                       /* display text */

      Comment

      Working...