Try it Live
Run Int examples in the interactive playground
Int8
Type-safe signed 8-bit integers with two’s complement encoding and EVM SDIV/SMOD semantics.Overview
Brandednumber type representing signed 8-bit integers (-128 to 127). Uses two’s complement representation for negative values and implements EVM signed division/modulo semantics.
Quick Start
- Basic Operations
- Two's Complement
- EVM Semantics
- Comparison & Sign
Two’s Complement Encoding
Negative values use two’s complement representation:| Decimal | Hex | Binary | Notes |
|---|---|---|---|
| 127 | 0x7F | 01111111 | INT8_MAX |
| 1 | 0x01 | 00000001 | Positive |
| 0 | 0x00 | 00000000 | Zero |
| -1 | 0xFF | 11111111 | All bits set |
| -128 | 0x80 | 10000000 | INT8_MIN (sign bit) |
- 0 = positive (0 to 127)
- 1 = negative (-128 to -1)
EVM SDIV/SMOD Semantics
Signed Division (SDIV)
Truncates toward zero (not toward negative infinity):Signed Modulo (SMOD)
Sign follows the dividend (first operand):Overflow Handling
All operations check for overflow:Arithmetic Right Shift
shiftRight preserves the sign bit (arithmetic shift):
Bitwise Operations
Bitwise operations work on two’s complement representation:Constructors
Conversions
Validation
Related
- Int16 - Signed 16-bit integers (-32768 to 32767)
- Uint - Unsigned 256-bit integers
- Opcode - EVM instructions (SDIV, SMOD)
References
- EVM SDIV - Signed division opcode
- EVM SMOD - Signed modulo opcode
- Two’s Complement - Wikipedia

