pub fn fixpoint_unit(float: f64, num: i64, den: i64) -> i64Expand description
Exact TeX fixed-point unit conversion: floor(round(float·65536)·num/den),
computed in integer (i128) arithmetic.
This is tex.web §458 scan_dimen — cur_val := xn_over_d(cur_val,num,denom); f := (num*f + 65536*remainder) div denom; cur_val += f div 65536 — which
algebraically collapses to floor(fix·num/den) for fix = cur_val·65536 + f
(proof: xn_over_d(x,n,d) = floor(x·n/d) with remainder = x·n mod d, so the
integer-part and fraction-carry terms recombine to num·fix/den). The
per-unit (num,den) come from crate::state::convert_unit_ratio (physical
units use TeX’s set_conversion fractions, tex.web 9020-9032; font-relative
units use (metric_sp, 65536), the nx_plus_y/xn_over_d path of §8983).
The legacy float fixpoint computes trunc(fix·(65536·num/den)/65536) and
drifts ±1 sp on rounding boundaries (verified against pdftex on cm/bp/mm/
cc; issue #127). Integer math is bit-faithful to TeX/pdfTeX. Sign matches
TeX: it tracks sign separately and floors the magnitude, i.e. truncation
toward zero — exactly Rust’s integer /.