Skip to main content

Module numeric

Module numeric 

Source
Expand description

Backend-neutral numeric boundary conversions. Backend-neutral numeric boundary conversions.

Concrete GPU backends cross the same host/API boundaries: host sizes become API u64s, high-resolution timers become telemetry u64s, and device timestamp deltas arrive as rounded floating-point nanoseconds. This module is the single policy for those lossy or fallible conversions; backend crates add only the backend label that makes the diagnostic actionable.

Structs§

BackendNumericPolicy
Backend-bound numeric conversion policy.

Constants§

BASIS_POINTS_DENOMINATOR
Integer basis-point denominator: 10_000 bps = 100%.

Functions§

align_up_u64
Align value upward to alignment, after applying min_value.
align_up_usize
Align value upward to alignment, after applying min_value.
checked_ceil_div_u64
Compute ceil(value / divisor) in u64, returning None for zero divisors or arithmetic overflow.
checked_compose_basis_points_u64
Compose two basis-point multipliers as (left * right) / 10_000, returning None rather than saturating when the composed value cannot fit u64.
checked_dim_product_u32
Multiply three u32 dimensions into a u32 without wraparound.
checked_dim_product_u64
Multiply three u32 dimensions into a u64 without wraparound.
compose_basis_points_u32
Compose two basis-point multipliers as (left * right) / 10_000, with widened arithmetic and loud u32 overflow pinning.
elapsed_nanos_u64
Convert elapsed wall-clock time to telemetry nanoseconds.
finite_f64_ratio_basis_points_round
Convert a finite floating-point ratio into rounded basis points, with separate policies for invalid numerators and denominators.
finite_f64_ratio_basis_points_trunc
Convert a finite floating-point ratio into floor basis points, with separate policies for invalid numerators and denominators.
finite_f64_to_u32_round
Convert a finite non-negative floating-point telemetry value to u32 after rounding to the nearest integer, with loud saturation on invalid input.
finite_f64_to_u32_trunc
Convert a finite non-negative floating-point telemetry value to u32 by truncating toward zero, with loud saturation on invalid or oversized input.
finite_f64_unit_basis_points_trunc
Convert a finite scalar where 1.0 == 10_000 bps into floor basis points.
ratio_basis_points_u64
Compute part / whole as floor basis points with explicit zero-denominator policy and saturating telemetry overflow.
ratio_basis_points_u64_wide
Compute part / whole as floor basis points in a u64 telemetry domain with explicit zero-denominator policy and loud overflow pinning.
ratio_parts_per_million_u64
Compute part / whole as floor parts-per-million with explicit zero-denominator policy and loud u32 overflow pinning.
rounded_f64_to_u64
Round a finite floating-point nanosecond value into telemetry storage.
scale_u64_by_basis_points_floor_min
Apply a basis-point multiplier to a u64 with floor rounding and an output lower bound.
scale_u64_by_basis_points_round_clamped
Apply a basis-point multiplier to a u64 with nearest-integer rounding, optional high clamp, and explicit zero-scale policy.
u128_to_u64
Convert a wide counter to telemetry u64.
usize_to_u64
Convert a host usize to a backend/API u64.
weighted_u64_by_basis_points_u128
Weight a u64 cost by basis points into a widened exact u128 domain.