+ 1
How to get ones compliment of a binary number using bitwise operator
Please help me
11 Respuestas
+ 2
To get the one's complement apply the unary bitwise not operator, ~.
+ 2
VENKATA SATHWIK REDDY DANDA suppose you wish to replace the value in k with its one's complement. It is a simple assignment:
k = ~k;
Now all of the bits in k are flipped opposite of what they were. Every 1 becomes 0, and every 0 becomes 1. That is one's complement.
+ 1
Thank you very much
+ 1
VENKATA SATHWIK REDDY DANDA your results are correct for a signed data type. Try using an unsigned data type. Also if you are using printf then change the format specifier to unsigned, like "%ud".
0
Will u pls write me the code
0
VENKATA SATHWIK REDDY DANDA you're welcome!
0
Brian I need to convert a number into binary and get ones compliment of obtained binary value pls help
0
Brian i tried like that but i am getting like this i gave 1010 i should get 0101 but getting -1011
0
Tq
0
Tq