Search

Sponsored Links

Meta

Categories

Archives

Recent Posts

RSS Feeds

25
Oct

Binary decimal conversion….

Related Blog Items

Here is a program to convert a binary string to decimal number.
ex. "0101" to 05

Parameters:
binary: is binary string
size: is size of the binary string buffer

int bin2dec(unsigned char *binary, int size)
{
  int i, result = 0;
 
  for(i = 0; i < size; i ++)
  {
    result += (binary[i] - '0') << (size - i - 1);
  }
 
  return result;
}

any comments welcome…

Popularity: 16%

You need to log on to convert this article into PDF


Related Blog Items

No Comments

No comments yet.

Leave a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image