pub fn convfloat(dval: f64, digits: i32, pm_flags: u32) -> StringExpand description
Port of convfloat(double dval, int digits, int flags, FILE *fout) from Src/params.c:5689.
C signature: char *convfloat(double dval, int digits, int flags, FILE *fout) — picks %e / %f / %g based on PM_EFLOAT /
PM_FFLOAT (line 5705-5727), then snprintf’d with digits precision.
When neither E nor F flag is set, zsh uses %.*g with a default
of 17 significant digits (line 5712-5714). E-flag with N significant
figures decrements digits because %e counts decimal places not
significants (line 5720-5725).
Rust signature drops the fout parameter — every caller wanted the
returned string. IEEE specials (inf/nan) hand-formatted to Inf/
-Inf/NaN ahead of the snprintf, matching the C source’s Inf/NaN
shortcuts at lines 5733-5736 / 5742-5744. The trailing-dot rule for
integer-valued floats (5 -> 5.) is added by the caller (params’
internal printing path) in C zsh; mirrored here for the no-flag case
so MathNum::(crate::ported::math::mn_format_subst(Float(5.0))) produces 5. not 5.
WARNING: param names don’t match C — Rust=(dval, digits, pm_flags) vs C=(dval, digits, flags, fout)