HdrHistogram / hdrhistogram-go

A pure Go implementation of Gil Tene's HDR Histogram.
MIT License
429 stars 64 forks source link

getBucketIndex calculates index wrong, overflows on small values #25

Closed aka-rider closed 7 years ago

aka-rider commented 7 years ago

There is an error in the following code pow2Ceiling := bitLen(v | h.subBucketMask)

Leading zero base is missing. In this case it is constant 64 pow2Ceiling := 64 - bitLen(v | h.subBucketMask)

codahale commented 7 years ago

I’d happily merge a pull request, but I don’t have time to investigate this myself.

aka-rider commented 7 years ago

Currently, I don't have a time to investigate it either.

aka-rider commented 7 years ago

Sorry, I was wrong. Reference implementation uses clz while yours uses 'bitLen'. That's where difference is.