Skip to main content

Module numeric_ops

Module numeric_ops 

Source

Constants§

EPSILON
MAX_DIMEN
TeX’s max_dimen (tex.web §421: 2^30 − 1 sp = 16383.99998pt), the bound arith_error clamps a scanned dimension to (“Dimension too large”, §460). LaTeXML keeps i64 headroom above it for pgf/tikz intermediates, so the clamp fires only where the value would not even fit an i64 — the pathology that wrapped to garbage (chinesechess.sty:2016-2020’s \coffin_scale:cnn{\dim_ratio:nn{…}{0}}, batch 56bq).
MAX_INTEGER
TeX’s infinity for integers (tex.web §445: 2^31 − 1), the \numexpr/ \multiply counterpart of MAX_DIMEN.
ROUNDING_HALF
SCALES
UNITY
UNITY_F64

Traits§

NumericOps

Functions§

clamp_arith_overflow
A product that left the i64 range (an infinite or saturated f64→i64 cast): TeX’s arith_error (“Arithmetic overflow”, tex.web §105-108) clamps to ±ceiling — MAX_DIMEN for a dimension, MAX_INTEGER for a count — never a wrapped value. An Error, as TeX’s (OXIDIZED_DESIGN #519); no Err channel here, so the cap latches as emit_error does. A Warning in a box measured by our approximation (approximated_measure).
fixpoint
Convert float to a fixed-point number
fixpoint_unit
Exact TeX fixed-point unit conversion: floor(round(float·65536)·num/den), computed in integer (i128) arithmetic.
fixpoint_unit_checked
fixpoint_unit that reports an i64 overflow as Err(sign) instead of wrapping the i128 product (the caller raises TeX’s arith_error).
kround
An attempt at rounding floats to integers (like scaled points), in a (hopefully) Knuthian manner (like round_decimals \S102 in Tex The Program)
round_decimals
TeX’s round_decimals (tex.web §102): the fraction .d₁d₂… of the decimal digits digits (the first 17 count), in scaled points, rounded half up.
round_to
Round $number to $prec decimals (0…6) attempting to do so portably.
scale_by_factor
<factor><dimen> as TeX’s scan_dimen multiplies them (tex.web §455): nx_plus_y(n, x, xn_over_d(x, f, 2^16)) for the factor n + f/2^16 (factor in scaled points), its sign attached after (§448). Not clamped: an overflow past max_dimen is the caller’s to report (§461).