Python Forum
NOT bit-wise operation question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NOT bit-wise operation question
#1
x = 4
y = 1

a = ~x

print(a)

Bit operation on 4 which equates to binary 100
what would be NOT operation on it?

I assumed that it would be binary 011 equating to decimal 3.
but the OpenEDG (edube.org) says the answer is decimal (-5) with no explanation.

Can someone throw a quick explanation as I didn't get its basics right probably.
Reply


Messages In This Thread
NOT bit-wise operation question - by ajayachander - Jan-27-2020, 07:14 AM
RE: NOT bit-wise operation question - by stranac - Jan-27-2020, 07:58 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner's String Operation question docboy 6 3,631 Sep-30-2018, 05:49 PM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020