Skip to content

std.math

Accepted

Accepted for V1 namespace ownership and the minimal min, max, and clamp helpers.

std.math owns numeric helpers and scalar algorithms.

Expected Contents

  • numeric helper functions
  • order-dependent scalar algorithms such as min, max, and clamp
  • alternate integer division and remainder helpers such as floor division, Euclidean division, and Euclidean modulo
  • float-specific APIs with explicit NaN policy
  • numeric constants and target-independent numeric utilities when needed

V1 accepts only these minimal order-dependent helpers:

pub fn min(comptime T: Ord(T), a: T, b: T) T
pub fn max(comptime T: Ord(T), a: T, b: T) T
pub fn clamp(comptime T: Ord(T), value: T, low: T, high: T) T

These require Ord(T), not merely PartialOrd(T), because unordered operands make result policy non-obvious. Float-specific min / max APIs may exist separately with explicit NaN policy.

V1 Boundary

Other math helpers, alternate integer division and modulo helpers, target behavior, numeric edge cases, float-specific policies, and constants are deferred to CEP-0054: Standard Utility APIs.