Aug 01

On taking one’s complement of a number, all 1’s in the number are changed to 0’s and all 0’s are changed to 1’s.

Example

let us take decimal no. 10.First this numberĀ  is converted to binary equivalent i.e. 0000000000001010,taking one’s complement,the number becomes 1111111111110101.

Syntax:

let m and j be declared as integer.

int m,j;

m= ~j;

Example

Decimal Original number(j) One’s complement(m)
1 0000000000000001 1111111111111110
2 0000000000000010 1111111111111101
3 0000000000000100 1111111111111011
4 0000000000001000 1111111111110111
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogplay
  • LinkedIn
  • MySpace
  • Reddit
  • RSS
  • Twitter

written by Shweta