Add note about pow-of-10 precision issue

Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
beorn7 2020-04-13 16:43:23 +02:00
parent d1f5366b52
commit a9d0066408
1 changed files with 5 additions and 0 deletions

View File

@ -531,6 +531,11 @@ func (h *histogram) observe(v float64, bucket int) {
case v < -h.sparseThreshold:
whichSparse = -1
}
// TODO(beorn7): This sometimes gives inaccurate results for
// floats that are actual powers of 10, e.g. math.Log10(0.1) is
// calculated as -0.9999999999999999 rather than -1 and thus
// yields a key unexpectedly one off. Maybe special-case precise
// powers of 10.
sparseKey = int(math.Ceil(math.Log10(math.Abs(v)) * float64(h.sparseResolution)))
}
// We increment h.countAndHotIdx so that the counter in the lower