Rust for Python Developers - Operators

Shin_O
58.5K views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

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.

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content