GH-1450: Improve printing/logging of large double/interval/time values

The modp_dtoa/modp_dtoa2 functions aren't capable of handling double
values larger than INT_MAX and fallback on using sprintf() in that
situation.  Previously, the format string to that sprintf() was "%e",
defaulting to a precision of 6, which is already too few digits to
represent a number known to be larger than INT_MAX.  Now, an sprintf()
is still performed for values larger than INT_MAX and still uses a
scientific notation format, but in a way that uses as many decimal
digits as needed to preserve information.
This commit is contained in:
Jon Siwek 2021-04-06 19:54:02 -07:00
parent ea8367713b
commit cc15c985ca
7 changed files with 88 additions and 19 deletions

View file

@ -1,6 +1,6 @@
#
# @TEST-EXEC: zeek -b %INPUT
# @TEST-EXEC: btest-diff test.log
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-openclose-timestamps btest-diff test.log
module Test;
@ -23,5 +23,6 @@ event zeek_init()
Log::write(Test::LOG, [$data=double_to_time(1234567890.00001)]);
Log::write(Test::LOG, [$data=double_to_time(1234567890.000001)]);
Log::write(Test::LOG, [$data=double_to_time(1234567890.0000001)]);
Log::write(Test::LOG, [$data=double_to_time(2385642157)]);
}