Solidity REPL
Math & units

Unchecked wraparound

Compare unchecked arithmetic when a uint8 passes its maximum.

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 unchecked wraparound so its input, result, and state changes stay easy to compare.

Solidity to run

uint8 value = 255
unchecked {
  value++
}
value

What to expect

The uint8 wraps from 255 to 0 inside the unchecked block and the wrapped value appears inline.

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