Bitwise and Conditional Operators
Explore how to apply bitwise operators to manipulate bits and use the conditional ternary operator for decisions in Solidity. This lesson helps you write concise, efficient smart contract code by mastering these operators' functions and syntax.
We'll cover the following...
In this lesson, we’ll explore bitwise and conditional operators in Solidity. These operators offer specialized capabilities that allow us to work with individual bits and create conditional expressions with concise syntax. Additionally, we’ll explore the conditional operator, which provides an elegant method for making decisions.
Bitwise operators
These operators are used to carry out operations at the bit level. The following bitwise operators are supported by Solidity:
Bitwise AND (
&): The boolean AND operation is applied to each bit of the integer input.Bitwise OR (
|): The boolean OR operation is applied to each bit of the integer input.Bitwise XOR (
^): The boolean exclusive OR (XOR) operation is applied to each bit of the integer input.Bitwise Not (
~): The boolean NOT operation is applied to each bit of the integer input. ...