Fixed wrong bounding/rounding

This commit is contained in:
Kilian Hofmann 2024-10-25 16:12:02 +02:00
parent f9123412e5
commit f4577bcddd
7 changed files with 6 additions and 6 deletions

View File

@ -131,5 +131,5 @@ int main() {
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
std::cout << "Mach for CI " << ci << ": " << aioMach << std::endl << std::endl;
std::cout << "END All-In-One, " << duration.count() << std::endl ;
std::cout << "END All-In-One, " << duration.count() << "ns" << std::endl ;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -35,10 +35,10 @@ float roundTo(float value, char decimals) {
}
/// @brief Bounding function for altitudes in accordance with data granularity
/// @param altitude Altitude in FL
/// @param altitude Altitude in ft
/// @return Lower bound in FL, upper bound in FL, ratio between bounds that equates to flightLevel
std::tuple<int, int, float> boundAltitude(float altitude) {
int flightLevel = (int)(altitude / 1000) * 10;
std::tuple<int, int, float> boundAltitude(int altitude) {
int flightLevel = (int)round(altitude / 100.0);
float lower = flightLevel - ((flightLevel - MIN_FL) % FL_STP);
float upper = (flightLevel - MIN_FL) % FL_STP != 0 ? lower + FL_STP : lower;
@ -51,11 +51,11 @@ std::tuple<int, int, float> boundAltitude(float altitude) {
/// @param weight Weight in kilogrammes
/// @return Lower bound in t, upper bound in t, ratio between bounds that equates to weight
std::tuple<int, int, float> boundWeight(int weight) {
int wgt = (int)(weight / 1000);
int wgt = (int)round(weight / 1000.0);
float lower = wgt - ((wgt - MIN_WGT) % WGT_STP);
float upper = (wgt - MIN_WGT) % WGT_STP != 0 ? lower + WGT_STP : lower;
float ratio = (wgt - lower) / WGT_STP;
float ratio = ((weight / 1000.0) - lower) / WGT_STP;
return {(int)lower, (int)upper, ratio};
}