Thread: Convert Binary Number into Integer

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    1

    Convert Binary Number into Integer

    What I need to do is convert a binary number into a integer when the binary number is stored as a int array? The binary number must be in an array.

  2. #2
    Registered User
    Join Date
    Apr 2011
    Location
    Belgium
    Posts
    1
    If Bin is the binary number that is stored as an array of integers:

    Code:
    int Bin[] = { 1, 1, 0, 1 };
    int Integer = Bin[3] + 2*Bin[2] + 4*Bin[1] + 8*Bin[0];
    Of cource the array must be bigger when the number it contains is bigger than 15.
    Last edited by texus; 04-14-2011 at 11:19 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help assignment due tomorrow
    By wildiv in forum C Programming
    Replies: 6
    Last Post: 01-27-2010, 08:38 PM
  2. memory issue
    By t014y in forum C Programming
    Replies: 2
    Last Post: 02-21-2009, 12:37 AM
  3. C++ program assistance needed
    By Velocity in forum C++ Programming
    Replies: 31
    Last Post: 10-05-2008, 09:08 PM
  4. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  5. Converting Sign Magnitude Integer Binary Files
    By Arthur Dent in forum C Programming
    Replies: 7
    Last Post: 09-13-2004, 10:07 AM

Tags for this Thread