Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
0.2.0 Preview 1 · Frozen documentation

Clamp

Restricts a value to one ordered inclusive numeric interval.

Sn is under heavy development. Reference extracted from this release’s bundled standard library. Public API examples are not an exhaustive compatibility test. Read the matching release guide for tested workflows and limitations. Read the status →

Module std.math

import std.math;

Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.

fn

pub const fn Clamp<T>(Value: T, Minimum: T, Maximum: T) -> T where T: Numeric, Copyable

Restricts a value to one ordered inclusive numeric interval. T: Copyable supported numeric representation. Value: Value to constrain; a NaN input propagates. Minimum: Inclusive lower bound. Maximum: Inclusive upper bound. Return: Value when in range, otherwise the selected bound; no allocation. Warning: Reversed or NaN bounds fatal-trap rather than silently swapping endpoints.

Documentation snapshot: October 24, 2026 About versions ↗
Searching Development · language & standard library