# Converting a short decimal into binary using a short not libary

• 09-26-2012
rockodan34
Converting a short decimal into binary using a short not libary
Converting a short decimal into binary using a short, no libary.
I just want help, it doesnt do anthing past the printf statment.

I dont want anyone to write the whole thing for me.

As i said im just lost and dont know what to do
Thank you so very much
still new to C programming.

Code:

` #include`
Code:

```<stdio.h> short inputnumber ; // the number taken from the user int temp; int j = 0; //counts the array loctions when printing int count;// equals the number you entered int i = 0;// counts the array loctions when it enters binary number int binout[16] ={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};// int _tmain(int argc, _TCHAR* argv[]) { //Asked user for their number printf("Please enter a number that is 16 bits\n"); //scans the user number scanf_s("%i",&inputnumber); count = inputnumber;// // useing mod to check if there is a remainer adding 1 if 0 or 1 if its a 1 doing 2's comp while ( count =! 0) if (count % 2 == 0 ){binout[i] = 1;count = count / 2;++i;}// else (binout[i] = 0); {count = count / 2; ++i;} //changing the first bit to the oppisite 2's comp if (binout[0] = 0) {binout[0] = 1;} else (binout[0] = 0); // printing you're number in binary while (j < 16, ++j ) {printf("You're number in 2's comp binary %i", &binout[j]);} return 0;} ```
• 09-26-2012
TheBigH
Code:

`printf("You're number in 2's comp binary %i", &binout[j]);`
%i prints an integer, but &binout[j] is an address.
• 09-26-2012
dmh2000
Code:

```else (binout[i] = 0); {count = count / 2; ++i;}```
what gets executed as the else?

Code:

`count =! 0`
what does this do?

edit:most microprocessors already represent their numbers internally as 2s-complement. since you are on Windows, the value is already in that format. unless i don't understand what you want to print, you don't need to swap that bit.
• 10-01-2012
rockodan34
How would you print the address? I want to put the binary represetation of an int into binout[] and print it out.
• 10-01-2012
rockodan34
You are right i'm trying to switch it to 2s complement. I understand windows does this for me but the program just need to show that i know how to do this.
• 10-01-2012
iMalc
If you need more help, please post the updated code after having fixed the things that were hinted at above.