in rtl/inc/khistogram.h [60:82]
NONPAGED void AddValue(ULONG64 value)
{
ULONG bias = (m_smallestValue > 0) ? 1 : 0;
if (value < m_smallestValue)
{
// The 0th bucket means "smaller than the minimum value"
IncrementBucket(0);
return;
}
auto offset = value - m_smallestValue;
auto largestValue = (m_numBuckets - 1 - bias) * m_bucketWidth;
if (offset >= largestValue)
{
// The last bucket means "bigger than the maximum value"
IncrementBucket(m_numBuckets - 1);
return;
}
auto bucket = offset / m_bucketWidth;
IncrementBucket(bucket + bias);
}