Skip to main content

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

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

Two’s Complement Encoding

Negative values use two’s complement representation:
DecimalHexBinaryNotes
1270x7F01111111INT8_MAX
10x0100000001Positive
00x0000000000Zero
-10xFF11111111All bits set
-1280x8010000000INT8_MIN (sign bit)
Bit 7 is the 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):
Contrast with logical right shift (would treat as unsigned).

Bitwise Operations

Bitwise operations work on two’s complement representation:

Constructors

Conversions

Validation

  • Int16 - Signed 16-bit integers (-32768 to 32767)
  • Uint - Unsigned 256-bit integers
  • Opcode - EVM instructions (SDIV, SMOD)

References