Try it Live
Run Int examples in the interactive playground
Int16
Type-safe signed 16-bit integers with two’s complement encoding and EVM SDIV/SMOD semantics.Overview
Brandednumber type representing signed 16-bit integers (-32768 to 32767). 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:
Bit 15 is the sign bit:
- 0 = positive (0 to 32767)
- 1 = negative (-32768 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
- Int8 - Signed 8-bit integers (-128 to 127)
- 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

