mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-01 05:33:49 +08:00
ui: replace static_cast<int> with std::nearbyint for convert & rounding (#1313)
* ui: replace `static_cast<int>` with `std::nearbyint` for precise rounding * revert
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -500,7 +501,7 @@ private:
|
||||
|
||||
int getParamValueScaled() {
|
||||
const auto param_value = QString::fromStdString(params.get(key));
|
||||
return static_cast<int>(param_value.toFloat() * 100);
|
||||
return std::nearbyint(param_value.toFloat() * 100.0f);
|
||||
}
|
||||
|
||||
void setParamValueScaled(const int new_value) {
|
||||
|
||||
Reference in New Issue
Block a user