fix ZAM "cat" of doubles/times to include trailing ".0" per normal BiF behavior

This commit is contained in:
Vern Paxson 2024-03-20 14:15:40 -07:00 committed by Tim Wojtulewicz
parent 86d1812d49
commit 4cafacf90b
5 changed files with 48 additions and 15 deletions

View file

@ -143,12 +143,7 @@ void ODesc::Add(double d, bool no_exp) {
Add(tmp);
auto approx_equal = [](double a, double b, double tolerance = 1e-6) -> bool {
auto v = a - b;
return v < 0 ? -v < tolerance : v < tolerance;
};
if ( approx_equal(d, nearbyint(d), 1e-9) && std::isfinite(d) && ! strchr(tmp, 'e') )
if ( util::approx_equal(d, nearbyint(d), 1e-9) && std::isfinite(d) && ! strchr(tmp, 'e') )
// disambiguate from integer
Add(".0");
}