aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2021-09-09 15:17:06 -0400
committerluigi1111 <luigi1111w@gmail.com>2021-09-09 15:17:06 -0400
commitaa8320671c0d8262a60ad2161467b6bedfaff17d (patch)
tree2ffd21e6b1e8df89af0137c8da538e650e78daf6 /contrib
parentMerge pull request #7855 (diff)
parentfix median overflow bug (diff)
downloadmonero-aa8320671c0d8262a60ad2161467b6bedfaff17d.tar.xz
Merge pull request #7858
426dbf4 fix median overflow bug (koe)
Diffstat (limited to 'contrib')
-rw-r--r--contrib/epee/include/stats.inl3
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/epee/include/stats.inl b/contrib/epee/include/stats.inl
index 5a5cd0b93..70c127be7 100644
--- a/contrib/epee/include/stats.inl
+++ b/contrib/epee/include/stats.inl
@@ -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);
}