渲染zh-Hans

numerus

Translation status: 简体中文 reader-locale proof. Code fences render through the zh-Hans pipeline; prose is canonical Latin.

Checked numerus arithmetic traps instead of wrapping on overflow.

Aliases: integer, int

Syntax: <numerus> + <numerus>

Category#

type

Examples#

radix/corpus/intrinseca/numerus-methodi.fab (canonical · keyword)#

Primitive integer number type.

# =============================================================================
# numerus — Primitive integer number type
# =============================================================================
#
# What this teaches:
#   • Primitive integer number type.
#   • Related keywords: fractus, ↦
#
# Common mistakes:
#   • Using `numerus` comparison methods on non-numeric types — `.absolutum()`, `.signum()`, `.minimus()`, `.maximus()` are numerus-only intrinsics.
#
# See also: fractus, ↦
# =============================================================================

# numerus comparison and ordering intrinsics
#
# Compiler-owned numerus methodi — absolutum, signum, minimus, maximus.
#
# GRAMMAR:
#   valor.absolutum() | valor.signum()
#   valor.minimus(other) | valor.maximus(other)
#
# Integer counterpart to fractus-comparatio.fab; Wasm tier Runnable.
#
# EXPECTED OUTPUT:
#   Smoke asserts exit 0 only.

main {
    const int value  -7
    const _ absolutus  value.absolutum()
    const _ signum  value.signum()
    const _ minor  value.minimus(3)
    const _ maior  value.maximus(3)

    print absolutus, signum, minor, maior
}

radix/corpus/operatores/numerus-overflow.fab (canonical · operator-group)#

Checked numerus arithmetic traps instead of wrapping on overflow.

# =============================================================================
# numerus — Checked numerus arithmetic traps instead of wrapping on overflow.
# =============================================================================
#
# What this teaches:
#   • Overflow safety — `numerus` (i64) traps on arithmetic overflow rather than wrapping.
#   • Policy distinction — Bare numerus follows checked semantics, unlike Rust's release-mode wrapping.
#
# Common mistakes:
#   • Assuming numerus wraps on overflow like modular word types.
#
# See also: +, numerus
# =============================================================================

# numerus-overflow — checked scalar arithmetic failure
#
# POLICY:
#   Bare `numerus` is i64. Integer arithmetic traps on overflow; it does not
#   inherit Rust release wrapping.

main {
    const int max  9223372036854775807
    print max + 1
}