C Programming - Convert an integer to binary -


I hope that after some suggestions for the resolution of the solution, because it is homework and I want to solve it myself < / P>

I am the first to be new to C. Actually I've never done it before, though I have a previous Java experience from the module in the university.

I am trying to write a program that changes an integer in the binary. I do not have permission to use only bitware operation and any library functions

Can anyone suggest some suggestions about how I will do this. Obviously I do not want the code or anything, just as some ideas to look for as present I'm a bit confused and there is no plan to attack. Well, it's very confusing: D

Thanks a lot

Think about What you can do with bitwise operators

Example You can check that the bit 1 or 0 is like this:

  int bit = value & amp; 1;  

You can also change bits in a bit like this:

  val = val> & Gt; 1;  

To test the i'th bit in an int, you can:

  int bit = (value> gt; & gt; I) & amp; 1;  

Hopefully you have enough signals to get started.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -