1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

convert a binary number to its 2’s compliment without the use of “~” (tilt) operator

Discussion in 'C' started by meghna, Mar 14, 2006.

  1. meghna

    meghna New Member

    Joined:
    Mar 14, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Write a 'C' Program to convert a binary number to its 2’s compliment without the use of “~” (tilt) operator.
     
  2. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    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.
     

Share This Page