Skip to content

Commit

Permalink
treat chris-durands review
Browse files Browse the repository at this point in the history
  • Loading branch information
TomSaw committed Jun 19, 2022
1 parent ce8a2d6 commit ce9bf1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/modm/math/proportional_unsigned.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,60 +99,60 @@ class ProportionalUnsigned {
ProportionalUnsigned
operator+(U value)
{
return {T(value_ + value) % (ProportionalUnsigned::max + 1)};
return {T(value_ + value) & ProportionalUnsigned::max};
}

template<std::integral U>
ProportionalUnsigned
operator-(U value)
{
return {T(value_ - value) % (ProportionalUnsigned::max + 1)};
return {T(value_ - value) & ProportionalUnsigned::max};
}

template<std::integral U>
ProportionalUnsigned
operator*(U value)
{
return {T(value_ * value) % (ProportionalUnsigned::max + 1)};
return {T(value_ * value) & ProportionalUnsigned::max};
}

template<std::integral U>
ProportionalUnsigned
operator/(U value)
{
return {T(value_ / value) % (ProportionalUnsigned::max + 1)};
return {T(value_ / value) & ProportionalUnsigned::max};
}

/// operator +=, -=, *=, /=
template<std::integral U>
ProportionalUnsigned&
operator+=(U value)
{
value_ = T(value_ + value) % (ProportionalUnsigned::max + 1);
value_ = T(value_ + value) & ProportionalUnsigned::max;
return *this;
}

template<std::integral U>
ProportionalUnsigned&
operator-=(U value)
{
value_ = T(value_ - value) % (ProportionalUnsigned::max + 1);
value_ = T(value_ - value) & ProportionalUnsigned::max;
return *this;
}

template<std::integral U>
ProportionalUnsigned&
operator*(U value)
{
value_ = T(value_ * value) % (ProportionalUnsigned::max + 1);
value_ = T(value_ * value) & ProportionalUnsigned::max;
return *this;
}

template<std::integral U>
ProportionalUnsigned&
operator/(U value)
{
value_ = T(value_ / value) % (ProportionalUnsigned::max + 1);
value_ = T(value_ / value) & ProportionalUnsigned::max;
return this;
}

Expand Down
8 changes: 4 additions & 4 deletions src/modm/math/utils/misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ pow(uint32_t base, uint8_t exponent)
* @see https://stackoverflow.com/questions/23815138/implementing-variadic-min-max-functions
*/
template<typename T>
constexpr T vmin(T a, T b)
constexpr T vmin(const T& a, const T& b)
{
return a < b ? a : b;
}

template<typename T, typename... Ts>
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...);
}
Expand All @@ -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<typename T>
constexpr T vmax(T& a, T& b)
constexpr T vmax(const T& a, const T& b)
{
return a > b ? a : b;
}

template<typename T, typename... Ts>
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...);
}
Expand Down
2 changes: 1 addition & 1 deletion test/config/hosted.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<modules>
<module>modm:platform:core</module>
<module>modm:driver:terminal</module>
<module>modm-test:test:**</module>
<module>modm-test:test:ui</module>
</modules>
</library>

0 comments on commit ce9bf1f

Please sign in to comment.