Home
Blogs
Questions
Jobs
Monetize

Home

About Us

Blogs

Questions

Jobs

Monetize

Post Job

banner

Questions about bitwise-not

Read more about bitwise-not

python (12.9k questions)

javascript (9.2k questions)

reactjs (4.7k questions)

java (4.2k questions)

java (4.2k questions)

c# (3.5k questions)

c# (3.5k questions)

html (3.3k questions)

Questions - bitwise-not

Bitwise not in python over unsigned numbers

I want to do a bitwise not in Python, but withouth taking care of the sign, as C would do. For example: >>> x = 4 >>> y = ~x >>> bin(x) '0b100' >>> bin(y) '0b101' ...
test-img

Dan

python

bit-manipulation

unsigned

bitwise-not

Votes: 0

Answers: 2

Latest Answer

Since Python ints are both signed and not a defined size of bits, the easiest way is to just XOR with an all 1's mask of the required bit length. For example to get a NOT for 4 bits: bin(x ^ 0b1111) ...
test-img

vaizki

Posts

Questions

Blogs

Jobs

The ultimate platform for coders and IT specialists

About

  • Company
  • Support

  • Platform

  • Terms & Conditions
  • Privacy statement
  • Cookie policy
  • Cookie option
  • OnlyCoders © 2025  |  All rights reserved