Solidity REPL
Math & units

Bitwise and modular math

Explore shifts, masks, addmod, and mulmod.

Solidity 0.8.36REPL mode

Why use this example

Use this pattern to confirm Solidity arithmetic and unit behavior before putting the same expression into a contract. The entry isolates bitwise and modular math so its input, result, and state changes stay easy to compare.

Solidity to run

uint256 flags = 0x2d
flags & 0x0f
flags << 2
addmod(8, 9, 5)
mulmod(8, 9, 5)

What to expect

The run shows the masked and shifted values followed by the deterministic addmod and mulmod results.

Continue the investigation

Change a value, add another expression, or open Inspect after the run. Accepted entries remain available to the next entry, and the clean replay keeps the complete result reproducible.

Read about writing Solidity Prototype Solidity behavior