Skip to main content

int

Pebble 0.3.1 · all symbols on this page are stable.

Arbitrary-precision signed integer. Maps to Plutus Core's Integer. Does not overflow.

Literals

FormExampleNotes
Decimal42, -7, 0The default form.
Underscore separator1_000_000Cosmetic; ignored at parse time.
Hexadecimal0xCAFECase-insensitive after the 0x.

Operators

CategoryOperators
Arithmetic+, -, *, / (floor division), % (floor modulo)
Comparison<, <=, >, >=, ==, !=
Unary- (negation)
Division semantics

/ and % round toward negative infinity (matching std.int.divide / std.int.mod). For C-style truncated division (toward zero), use std.int.quotient / std.int.remainder.

Methods

int has no method-call surface. All operations are via operators or the std.int namespace.

Common idioms:

Want…Use
Modular exponentiationstd.builtins.expModInteger(base, exp, m)
int → bytes (smallest fit)std.bytes.fromInt(n)
int → bytes (fixed width)std.builtins.integerToByteString(true, size, n)
int → boolstd.int.toBoolean(n)
Encoded as datan.toData() (ToData) — uses iData

See also

  • std.int — function-call surface
  • bytes — conversion target
  • ToData — auto-derived .toData()