Skip to content

Commit

Permalink
Added check to convert -0.0f to 0.0f in map functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
sofian committed Aug 14, 2024
1 parent 1a841da commit 1af2ec4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pq_map_real.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
namespace pq {

float _mapConvert(float value, float toLow, float toHigh, uint8_t mode) {
// Return and constrain.
// Convert -0.0f to 0.0f
if (value == 0.0f)
value = 0.0f;

// Apply mode and return.
switch (mode) {
case UNCONSTRAIN: return value;
case CONSTRAIN: return toLow <= toHigh ? constrain(value, toLow, toHigh) : constrain(value, toHigh, toLow);
Expand Down

0 comments on commit 1af2ec4

Please sign in to comment.