diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-07-19 15:25:20 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-07-19 16:02:16 +0300 |
commit | b9185f90067bd0294b907e1e5a0c282f9b5e00ed (patch) | |
tree | 7aac70655910c1351e04adafca154ba6026fe070 | |
parent | fbd9b043aa07b49a157fbdc0eaf15b141564600c (diff) | |
download | qtlocation-mapboxgl-b9185f90067bd0294b907e1e5a0c282f9b5e00ed.tar.gz |
[core] util::wrap(): std::fmod is not lossless
-rw-r--r-- | include/mbgl/math/wrap.hpp | 5 |
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; } |