Skip to main content

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

Branded number 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

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):
Contrast with logical right shift (would treat as unsigned).

Bitwise Operations

Bitwise operations work on two’s complement representation:

Constructors

Conversions

Validation

  • Int8 - Signed 8-bit integers (-128 to 127)
  • Uint - Unsigned 256-bit integers
  • Opcode - EVM instructions (SDIV, SMOD)

References