Back
Close

Rust for Python Developers - Operators

Shin_O
58.9K views

This article was originally published on Medium

Follow me:

Bitwise Operators

All the Rust and Python Bitwise operators share the same bitwise operator symbols except the bitwise NOT.

MeaningPythonRust
Bitwise AND&&
Bitwise OR||
Bitwise NOT~!
Bitwise XOR^^
Bitwise right shift>>>>
Bitwise left shift<<<<

Bitwise negation !1 returns -2. Rust uses the two’s complement to find the bitwise negation for signed types. Rust’s signed integer types are called the signed two’s complement integer types.

You can use 1 << n to find out exponents of 2.

Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io