Browse Source

Fix math::normalizeZero() which had no effect due to float optimization. Normalize zero in PortTooltip.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
2f0bada0a5
2 changed files with 3 additions and 1 deletions
  1. +1
    -0
      include/math.hpp
  2. +2
    -1
      src/app/PortWidget.cpp

+ 1
- 0
include/math.hpp View File

@@ -118,6 +118,7 @@ inline float clampSafe(float x, float a = 0.f, float b = 1.f) {
}

/** Converts -0.f to 0.f. Leaves all other values unchanged. */
__attribute__((optimize("signed-zeros")))
inline float normalizeZero(float x) {
return x + 0.f;
}


+ 2
- 1
src/app/PortWidget.cpp View File

@@ -32,11 +32,12 @@ struct PortTooltip : ui::Tooltip {
// Voltage, number of channels
int channels = port->getChannels();
for (int i = 0; i < channels; i++) {
float v = port->getVoltage(i);
// Add newline or comma
text += "\n";
if (channels > 1)
text += string::f("%d: ", i + 1);
text += string::f("% .3fV", port->getVoltage(i));
text += string::f("% .3fV", math::normalizeZero(v));
}
// Connected to
std::list<CableWidget*> cables = APP->scene->rack->getCablesOnPort(portWidget);


Loading…
Cancel
Save