From 4ef2ae0b7444be7f3c4c401ad80a9ffd1e3c6e15 Mon Sep 17 00:00:00 2001 From: Thomas Sommer Date: Sun, 19 Jun 2022 17:47:40 +0200 Subject: [PATCH] treat chris-durands review --- src/modm/math/proportional_unsigned.hpp | 16 ++++++++-------- src/modm/math/utils/misc.hpp | 8 ++++---- test/config/hosted.xml | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/modm/math/proportional_unsigned.hpp b/src/modm/math/proportional_unsigned.hpp index cf58e592a0..97c4915ebf 100644 --- a/src/modm/math/proportional_unsigned.hpp +++ b/src/modm/math/proportional_unsigned.hpp @@ -99,28 +99,28 @@ class ProportionalUnsigned { ProportionalUnsigned operator+(U value) { - return {T(value_ + value) % (ProportionalUnsigned::max + 1)}; + return {T(value_ + value) & ProportionalUnsigned::max}; } template ProportionalUnsigned operator-(U value) { - return {T(value_ - value) % (ProportionalUnsigned::max + 1)}; + return {T(value_ - value) & ProportionalUnsigned::max}; } template ProportionalUnsigned operator*(U value) { - return {T(value_ * value) % (ProportionalUnsigned::max + 1)}; + return {T(value_ * value) & ProportionalUnsigned::max}; } template ProportionalUnsigned operator/(U value) { - return {T(value_ / value) % (ProportionalUnsigned::max + 1)}; + return {T(value_ / value) & ProportionalUnsigned::max}; } /// operator +=, -=, *=, /= @@ -128,7 +128,7 @@ class ProportionalUnsigned { ProportionalUnsigned& operator+=(U value) { - value_ = T(value_ + value) % (ProportionalUnsigned::max + 1); + value_ = T(value_ + value) & ProportionalUnsigned::max; return *this; } @@ -136,7 +136,7 @@ class ProportionalUnsigned { ProportionalUnsigned& operator-=(U value) { - value_ = T(value_ - value) % (ProportionalUnsigned::max + 1); + value_ = T(value_ - value) & ProportionalUnsigned::max; return *this; } @@ -144,7 +144,7 @@ class ProportionalUnsigned { ProportionalUnsigned& operator*(U value) { - value_ = T(value_ * value) % (ProportionalUnsigned::max + 1); + value_ = T(value_ * value) & ProportionalUnsigned::max; return *this; } @@ -152,7 +152,7 @@ class ProportionalUnsigned { ProportionalUnsigned& operator/(U value) { - value_ = T(value_ / value) % (ProportionalUnsigned::max + 1); + value_ = T(value_ / value) & ProportionalUnsigned::max; return this; } diff --git a/src/modm/math/utils/misc.hpp b/src/modm/math/utils/misc.hpp index 04b9fb57b4..4b4cb5b732 100644 --- a/src/modm/math/utils/misc.hpp +++ b/src/modm/math/utils/misc.hpp @@ -68,13 +68,13 @@ pow(uint32_t base, uint8_t exponent) * @see https://stackoverflow.com/questions/23815138/implementing-variadic-min-max-functions */ template -constexpr T vmin(T a, T b) +constexpr T vmin(const T& a, const T& b) { return a < b ? a : b; } template -constexpr T vmin(T a, T b, Ts&&... cs) +constexpr T vmin(const T& a, const T& b, const Ts&... cs) { return a < b ? vmin(a, cs...) : vmin(b, cs...); } @@ -91,13 +91,13 @@ constexpr T vmin(T a, T b, Ts&&... cs) * @see https://stackoverflow.com/questions/23815138/implementing-variadic-min-max-functions */ template -constexpr T vmax(T& a, T& b) +constexpr T vmax(const T& a, const T& b) { return a > b ? a : b; } template -constexpr T vmax(T& a, T& b, Ts&... cs) +constexpr T vmax(const T& a, const T& b, const Ts&... cs) { return a > b ? vmax(a, cs...) : vmax(b, cs...); } diff --git a/test/config/hosted.xml b/test/config/hosted.xml index 660ea5c22f..8939a83d57 100644 --- a/test/config/hosted.xml +++ b/test/config/hosted.xml @@ -7,6 +7,6 @@ modm:platform:core modm:driver:terminal - modm-test:test:** + modm-test:test:ui