summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2018-07-19 15:25:20 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2018-07-30 15:34:11 +0300
commitba411cf421e0254bfd89c60ee10384f5e19cff10 (patch)
tree8610f5f031f4910a0854bb87a63abfc1e2b663b2
parent91ce4840ad7ee0d5d41b79edf97b6c98cae5671c (diff)
downloadqtlocation-mapboxgl-ba411cf421e0254bfd89c60ee10384f5e19cff10.tar.gz
[core] util::wrap(): std::fmod is not lossless
-rw-r--r--include/mbgl/math/wrap.hpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/mbgl/math/wrap.hpp b/include/mbgl/math/wrap.hpp
index 16dc598c22..8a9303edc2 100644
--- a/include/mbgl/math/wrap.hpp
+++ b/include/mbgl/math/wrap.hpp
@@ -9,6 +9,11 @@ namespace util {
// arithmetic.
template <typename T>
T wrap(T value, T min, T max) {
+ if (value >= min && value < max) {
+ return value;
+ } else if (value == max) {
+ return min;
+ }
T d = max - min;
return std::fmod((std::fmod((value - min), d) + d), d) + min;
}