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
| Form | Example | Notes |
|---|---|---|
| Decimal | 42, -7, 0 | The default form. |
| Underscore separator | 1_000_000 | Cosmetic; ignored at parse time. |
| Hexadecimal | 0xCAFE | Case-insensitive after the 0x. |
Operators
| Category | Operators |
|---|---|
| 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 exponentiation | std.builtins.expModInteger(base, exp, m) |
int → bytes (smallest fit) | std.bytes.fromInt(n) |
int → bytes (fixed width) | std.builtins.integerToByteString(true, size, n) |
int → bool | std.int.toBoolean(n) |
Encoded as data | n.toData() (ToData) — uses iData |