C 1′s Compliment Operator
One’s Compliment Operator in C
- It is denoted by ~
- Bit Pattern of the data can be Reversed using One’s Compliment
- It inverts each bit of operand .
- One’s Compliment is Unary Operand i.e Operates on 1 Argument
Original Number A | 0000 0000 0011 1100 |
One’sCompliment | 1111 1111 1100 0011 |
Zero’s Are Changed to | 1 |
One’s Are Changed to | 0 |
Syntax :
~Variable_Name
Live Example : Negation Operator in C Programming
#include<stdio.h> int main() { int a=10; printf("\nNegation of Number 1 : %d",~a); return(0); }
Output :
Negation of Number 1 : -11