Back
Close

Rust for Python Developers - Operators

Shin_O
2,278 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
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants