mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
fix ZAM "cat" of doubles/times to include trailing ".0" per normal BiF behavior
This commit is contained in:
parent
86d1812d49
commit
4cafacf90b
5 changed files with 48 additions and 15 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue