Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   convert a binary number to its 2s compliment without the use of ~ (tilt) operator (http://www.go4expert.com/forums/convert-binary-2s-compliment-tilt-t631/)

meghna 14Mar2006 10:41

convert a binary number to its 2s compliment without the use of ~ (tilt) operator
 
Write a 'C' Program to convert a binary number to its 2s compliment without the use of ~ (tilt) operator.

coderzone 14Mar2006 11:57

Re: convert a binary number to its 2s compliment without the use of ~ (tilt) operator
 
A two's complement number, invert all the bits then add 1 to the result.

To invert a bit without using the "~" use the XOR operator. XOR operator needed to be done with all one's and that will invert the no then adding one will give the 2's compliment.


All times are GMT +5.5. The time now is 03:30.