This is in juce_MathsFunctions.h. To start off, here’s findMinimum:

[code] /** Scans an array of values, returning the minimum value that it contains. */
template
const Type findMinimum (const Type* data, int numValues)

{

if (numValues <= 0)

return Type();

```
Type result (*data++);
while (--numValues > 0) // (> 0 rather than >= 0 because we've already taken the first sample)
{
const Type& v = *data++;
if (v < result) result = v;
}
return result;
```

}[/code]

Makes sense. Now here’s findMaximum():

[code]/** Scans an array of values, returning the minimum value that it contains. */
template
const Type findMaximum (const Type* values, int numValues)

{

if (numValues <= 0)

return Type();

```
Type result (*values++);
while (--numValues > 0) // (> 0 rather than >= 0 because we've already taken the first sample)
{
const Type& v = *values++;
if (result > v) result = v;
}
return result;
```

}[/code]

You can see the comment at the top for findMaximum still says it finds the minimum, but that’s not the problem. The problem is that findMinimum is doing this:

```
if (v < result) result = v;
```

and findMaximum is doing this

```
if (result > v) result = v;
```

which are the same thing.