Merge pull request #7858

426dbf4 fix median overflow bug (koe)
This commit is contained in:
luigi1111 2021-09-09 15:17:06 -04:00
commit aa8320671c
No known key found for this signature in database
GPG key ID: F4ACA0183641E010

View file

@ -1,6 +1,7 @@
#include <math.h>
#include <limits>
#include <algorithm>
#include "misc_language.h"
#include "stats.h"
enum
@ -86,7 +87,7 @@ Tpod Stats<T, Tpod>::get_median() const
}
else
{
median = (sorted[(sorted.size() - 1) / 2] + sorted[sorted.size() / 2]) / 2;
median = epee::misc_utils::get_mid(sorted[(sorted.size() - 1) / 2], sorted[sorted.size() / 2]);
}
set_cached(bit_median);
}