diff --git a/executor.go b/executor.go index 142033a29..15d6fb571 100644 --- a/executor.go +++ b/executor.go @@ -1298,6 +1298,7 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string // compute average without integer overflow, then correct for division of // odd numbers by 2 possibleNthVal := ((max / 2) + (min / 2)) + (((max % 2) + (min % 2)) / 2) + // possibleNthVal = (max + min) / 2 // get left count rangeCall.Args[fieldName] = &pql.Condition{ Op: pql.Token(pql.LT), diff --git a/executor_test.go b/executor_test.go index 2b37c36b2..9427914b2 100644 --- a/executor_test.go +++ b/executor_test.go @@ -6939,7 +6939,7 @@ func variousQueriesOnPercentiles(t *testing.T, c *test.Cluster) { possibleNthVal := int64(0) // bin search for min < max { - possibleNthVal = (max + min) / 2 + possibleNthVal = ((max / 2) + (min / 2)) + (((max % 2) + (min % 2)) / 2) leftCount, rightCount := int64(0), int64(0) for _, num := range nums { if num < possibleNthVal {