int256

int256 is not implemented in the current release.
PropertyValue
Size32 bytes (256 bits)
Minimum value−2255 ≈ −5.789604 × 1076
Maximum value2255−1 ≈ 5.789604 × 1076
Literal suffixi256
RepresentationTwo's complement
Hardware supportSoftware-emulated on all targets

int256 is a big-integer type for cryptographic arithmetic — a fixed-width type whose size is identical on every target platform. Like all signed types it uses two's complement: the most significant bit is the sign bit. No mainstream CPU has native 256-bit arithmetic, so every operation is software-emulated; reach for it when correctness and portability matter more than raw throughput.

Literals

let a: int256 = 1;  // explicit annotation
let b = 42i256;     // type suffix

If a literal value does not fit in int256, the compiler emits an error at compile time. See Literals for decimal, hexadecimal, octal, and binary forms.

Typical Use Cases

  • Cryptographic big-integer arithmetic
  • Elliptic-curve field elements

Arithmetic

OperatorDescriptionCompound
+Addition+=
-Subtraction-=
*Multiplication*=
/Division/=
%Remainder%=
**Exponentiationn/a
let a: int256 = 10;
let b: int256 = 3;

let sum  = a + b;   // 13
let quot = a / b;   // 3   truncates toward zero
let rem  = a % b;   // 1   carries the sign of the dividend

Division and remainder truncate toward zero, so the remainder takes the sign of the dividend: -7 % 2 is -1.

Overflow. In debug builds, signed overflow raises a fatal error. In release builds it wraps modulo 2256 in two's-complement fashion. Wraparound is well-defined in Rux (unlike C/C++), but relying on it is almost always a logic error.

Comparison

OperatorDescriptionResult
==Equalbool
!=Not equalbool
<Less thanbool
<=Less than or equalbool
>Greater thanbool
>=Greater than or equalbool

Both operands must have the same type. Comparing int256 with another integer type — or with an unsigned type such as uint256 — is a compile-time error; cast one operand explicitly first.

Shift and Bitwise

Right shift with >> on a signed value is arithmetic: vacated bits are filled with the sign bit, preserving the sign. To fill with zeros instead, use the logical right shift >>>, which keeps the same signed type and width.

let s: int256 = -8;
let r = s >> 2;     // -2   sign-filled (arithmetic) right shift

The bitwise operators &, |, ^, and ~ are also defined (~x equals −(x + 1)), but bitmask work usually reads more clearly on unsigned types.

Conversion

Rux performs no implicit numeric conversions — every conversion uses the as operator. Widening to a wider signed type preserves the value through sign extension; narrowing keeps only the low-order bits; a same-width signed↔unsigned cast reinterprets the bit pattern.

let x: int256 = -1;
let small = x as int64;    // -1   narrowed, low 64 bits kept
let u     = x as uint256;  // 2^256 − 1   same width, bits reinterpreted

See Also