Commit graph

10 commits

Author SHA1 Message Date
Jon Siwek
8996dfbfef Omit unneeded decimal points in modp_dtoa2() scientific notation output
For example, "1e-13" is now used instead of "1.e-13".
2021-05-17 17:56:19 -07:00
Jon Siwek
48ee0f31a1 GH-1244: Change modp_dtoa2() to use scientific notation for small values
This fixes problems where printing floating point numbers less than
10^-6 output as "0.0".  Such numbers now use using scientific notation
and preserve the value's actual floating point representation.
2021-05-17 17:44:23 -07:00
Jon Siwek
cc15c985ca 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.
2021-04-06 19:54:02 -07:00
Tim Wojtulewicz
96d9115360 GH-1079: Use full paths starting with zeek/ when including files 2020-11-12 12:15:26 -07:00
Jon Siwek
17e3392052 Avoid unary negation of INT64_MIN in modp_litoa10
Overlow can occur in that case, which is undefined behavior.
2020-09-18 11:32:05 -07:00
Jon Siwek
d25ead8f8e Avoid double-to-int conversion overflows in modp_dtoa functions
Those methods already had a fallback to use sprintf() for large values
except:

* The check-for-large-value was unnecessarily done after many
  operations that aren't relevant to the check and those operations can
  result in a conversion overflow (undefined behavior).

* The check-for-large-value was using the literal value for a
  32-bit INT_MAX instead of just using INT_MAX.  For a platform where
  `int` is less than 32-bits, the same conversion overflow from the
  previous point could still occur (undefined behavior).

* The check-for-large-value was not inclusive of INT_MAX.
  In a case where the conversion of INT_MAX itself to a double
  can't be represented exactly, it's implementation-defined whether
  the closest higher or closest lower representable-value is selected.
  If the higher value is selected, then a `double` value comparing equal
  to INT_MAX-as-converted-to-double would cause an overflow of an `int`
  upon conversion (undefined behavior).
2020-09-18 11:32:05 -07:00
Robin Sommer
d86bf15dbf Do not use scientific notations when printing doubles in logs.
Closes BIT-1558.
2016-05-23 16:07:22 -07:00
Robin Sommer
a24abddc5f Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath:
  Remove automatic use of gperftools on non-Linux systems.
  Fix uninitialized value for 'is_partial' in TCP analyzer.
  parse 64-bit consts correctly.
  on 32-bit machines only unsigned long longs are 64-bits long. Not just unsigned longs...
2012-08-28 16:35:06 -07:00
Bernhard Amann
26f5aee7f6 on 32-bit machines only unsigned long longs are 64-bits long. Not just unsigned longs...
Note that this means that up to now all outputs (including logs) of counts > 32 bits were broken on 32-bit systems.
2012-08-28 00:44:39 -07:00
Robin Sommer
8aaccf1c95 Logging speed improvements.
We now use Google's replacement functions for slow printf-based
num-to-ascii conversion.
2011-10-06 15:55:45 -07:00