Standard library · Bits
- The language
- Agents and tools
- Model providers
- The Anthropic API
- Talking agents
- Standard library
- Glossary
- Package docs
- Telemetry
- Robots
- Servers
- Deploying
- tin.ad
- The tin command
- How it works
On this page
Bits
Rotations and wrapping arithmetic for checksums and hashes, where overflow is meant to wrap.
Example
print(255.rotl(8))
print(2147483647.wrapAdd(1))
print((-1).u32()) 65280
-2147483648
4294967295 All 11 symbols
int.rotlint.rotrint.wrapAddint.wrapSubint.wrapMulint.u32i64.rotli64.rotri64.wrapAddi64.wrapMuli64.lo32
int.rotl
fn int.rotl(x: int, n: int): int The 32 bits of x rotated left by n (any n; taken mod 32).
int.rotr
fn int.rotr(x: int, n: int): int The 32 bits of x rotated right by n (any n; taken mod 32).
int.wrapAdd
fn int.wrapAdd(x: int, y: int): int x + y wrapping around at 32 bits (hashes, checksums); plain + panics on overflow.
int.wrapSub
fn int.wrapSub(x: int, y: int): int x - y wrapping around at 32 bits.
int.wrapMul
fn int.wrapMul(x: int, y: int): int x * y wrapping around at 32 bits.
int.u32
fn int.u32(x: int): i64 The 32 bits of x read as unsigned: 0..4294967295.
i64.rotl
fn i64.rotl(x: i64, n: int): i64 No summary yet; the signature is the whole description.
i64.rotr
fn i64.rotr(x: i64, n: int): i64 No summary yet; the signature is the whole description.
i64.wrapAdd
fn i64.wrapAdd(x: i64, y: i64): i64 No summary yet; the signature is the whole description.
i64.wrapMul
fn i64.wrapMul(x: i64, y: i64): i64 No summary yet; the signature is the whole description.
i64.lo32
fn i64.lo32(x: i64): int The low 32 bits of x as an int (wraps: 0xFFFFFFFF becomes -1). int(x) panics instead.