Unary operator!!!?!? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Unary operator!!!?!?

I got stuck....in unary operator...a=10 ;b=-10; (~a)=-11 ..(~b)=9.... ~a=-11 this is understood as like 0 to 10 is 11 number and for ~ it is -11 But how (~b) =9;

6th Jun 2018, 11:10 AM
Ferdous Rayhan
Ferdous Rayhan - avatar
1 Answer
+ 23
~ flips the bits in the binary form of a number... b = -10 = 1111... 1111 1111 0110 ~b = 0000... 0000 0000 1001 = 9(decimal) https://www.sololearn.com/learn/4076/?ref=app Use this code to convert decimal number to binary and apply the bitwise complement 👇 https://code.sololearn.com/cDWx71pvFez9/?ref=app
6th Jun 2018, 11:14 AM
🌛DT🌜
🌛DT🌜 - avatar